From fe427341f29a31656e247ef528adbab5ad786c9e Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Fri, 31 Jul 2015 21:50:33 -0700 Subject: Decoder fix: skipped data at end of submessage. --- tests/pb/test_decoder.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'tests/pb/test_decoder.cc') diff --git a/tests/pb/test_decoder.cc b/tests/pb/test_decoder.cc index 310f8c1..78dd7dc 100644 --- a/tests/pb/test_decoder.cc +++ b/tests/pb/test_decoder.cc @@ -138,7 +138,7 @@ void PrintBinary(const string& str) { if (isprint(str[i])) { fprintf(stderr, "%c", str[i]); } else { - fprintf(stderr, "\\x%02x", str[i]); + fprintf(stderr, "\\x%02x", (int)(uint8_t)str[i]); } } } @@ -575,7 +575,6 @@ void do_run_decoder(VerboseParserEnvironment* env, upb::pb::Decoder* decoder, } else { fprintf(stderr, "Expected to FAIL\n"); } - fprintf(stderr, "Calling start()\n"); } bool ok = env->Start() && @@ -941,6 +940,20 @@ void test_valid() { submsg(12345, string(" ")), "<\n>\n"); + // Unknown field inside a known submessage. + assert_successful_parse( + cat (submsg(UPB_DESCRIPTOR_TYPE_MESSAGE, + submsg(12345, string(" "))), + tag(UPB_DESCRIPTOR_TYPE_INT32, UPB_WIRE_TYPE_VARINT), + varint(5)), + LINE("<") + LINE("%u:{") + LINE(" <") + LINE(" >") + LINE("}") + LINE("%u:5") + LINE(">"), UPB_DESCRIPTOR_TYPE_MESSAGE, UPB_DESCRIPTOR_TYPE_INT32); + // This triggered a previous bug in the decoder. assert_successful_parse( cat( tag(UPB_DESCRIPTOR_TYPE_SFIXED32, UPB_WIRE_TYPE_VARINT), -- cgit v1.2.3