From 46ddd14efd744284f6c0c0179ceb6ccecc3e9bbe Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Mon, 24 Jul 2023 08:16:09 -0700 Subject: [PATCH] Treat kParseError logically kDirty. PiperOrigin-RevId: 550564661 --- src/google/protobuf/message_unittest.inc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/google/protobuf/message_unittest.inc b/src/google/protobuf/message_unittest.inc index 91c88e8c29..4aaf7ee53f 100644 --- a/src/google/protobuf/message_unittest.inc +++ b/src/google/protobuf/message_unittest.inc @@ -342,6 +342,16 @@ TEST(MESSAGE_TEST_NAME, ExplicitLazyExceedRecursionLimit) { EXPECT_NE(parsed.lazy_child().child().payload().optional_int32(), -1); } +TEST(MESSAGE_TEST_NAME, UnparsedEmpty) { + // lazy_child, LEN=100 with no payload. + const char encoded[] = {'\042', 100}; + UNITTEST::NestedTestAllTypes message; + + EXPECT_FALSE(message.ParseFromArray(encoded, sizeof(encoded))); + EXPECT_TRUE(message.has_lazy_child()); + EXPECT_EQ(message.lazy_child().ByteSizeLong(), 0); +} + TEST(MESSAGE_TEST_NAME, ParseFailNonCanonicalZeroTag) { const char encoded[] = {"\n\x3\x80\0\0"}; UNITTEST::NestedTestAllTypes parsed;