Skip to content

Commit 34f7bb0

Browse files
pranavtbhatmeta-codesync[bot]
authored andcommitted
Fix stack-overflow in ttype-debug
Summary: Fix infinte recursion bug for unknown ttypes Reviewed By: hchokshi, iahs Differential Revision: D90136336 fbshipit-source-id: 168d135a3577ea99d53cfc7ef9c5ce36ed1a67b8
1 parent db9a790 commit 34f7bb0

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

third-party/thrift/src/thrift/lib/cpp/protocol/TType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ std::string debugStringForTType(TType type) {
5959
case T_FLOAT:
6060
return "FLOAT";
6161
default:
62-
return fmt::format("UNKNOWN({})", type);
62+
return fmt::format("UNKNOWN({})", static_cast<uint8_t>(type));
6363
}
6464
}
6565

third-party/thrift/src/thrift/lib/cpp2/protocol/test/ProtocolTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ static constexpr size_t kTestingProtocolMaxDepth = 4;
3636
TEST(TTypeTest, Format) {
3737
EXPECT_EQ(fmt::format("{}", T_BOOL), "BOOL");
3838
EXPECT_EQ(fmt::format("{}", T_I64), "I64");
39+
40+
auto uint8Max = std::numeric_limits<uint8_t>::max();
41+
EXPECT_EQ(
42+
fmt::format("{}", static_cast<TType>(uint8Max)),
43+
fmt::format("UNKNOWN({})", uint8Max));
3944
}
4045

4146
template <typename ProtocolWriter>

0 commit comments

Comments
 (0)