@@ -857,8 +857,9 @@ TORRENT_TEST(parse_int)
857
857
{
858
858
char b[] = " 1234567890e" ;
859
859
std::int64_t val = 0 ;
860
- bdecode_errors::error_code_enum ec;
860
+ bdecode_errors::error_code_enum ec = bdecode_errors::no_error ;
861
861
char const * e = parse_int (b, b + sizeof (b)-1 , ' e' , val, ec);
862
+ TEST_EQUAL (ec, bdecode_errors::no_error);
862
863
TEST_EQUAL (val, 1234567890 );
863
864
TEST_EQUAL (e, b + sizeof (b) - 2 );
864
865
}
@@ -901,7 +902,7 @@ TORRENT_TEST(parse_length_overflow)
901
902
bdecode_node e;
902
903
int ret = bdecode (b[i], b[i] + strlen (b[i]), e, ec);
903
904
TEST_EQUAL (ret, -1 );
904
- TEST_CHECK (ec == error_code (bdecode_errors::unexpected_eof));
905
+ TEST_EQUAL (ec, error_code (bdecode_errors::unexpected_eof));
905
906
}
906
907
}
907
908
@@ -910,9 +911,9 @@ TORRENT_TEST(expected_colon_string)
910
911
{
911
912
char b[] = " 928" ;
912
913
std::int64_t val = 0 ;
913
- bdecode_errors::error_code_enum ec;
914
+ bdecode_errors::error_code_enum ec = bdecode_errors::no_error ;
914
915
char const * e = parse_int (b, b + sizeof (b)-1 , ' :' , val, ec);
915
- TEST_EQUAL (ec, bdecode_errors::expected_colon );
916
+ TEST_EQUAL (ec, bdecode_errors::no_error );
916
917
TEST_EQUAL (e, b + 3 );
917
918
}
918
919
@@ -1395,6 +1396,21 @@ TORRENT_TEST(partial_parse4)
1395
1396
TEST_EQUAL (print_entry (e), " { 'a': 1, 'b': 'foo', 'c': [ 1 ] }" );
1396
1397
}
1397
1398
1399
+ TORRENT_TEST (partial_parse_string)
1400
+ {
1401
+ // it's important to not have a null terminator here
1402
+ // to allow address sanitizer to trigger in case the decoder reads past the
1403
+ // end
1404
+ char b[] = { ' 5' , ' 5' };
1405
+
1406
+ bdecode_node e;
1407
+ error_code ec;
1408
+ int pos;
1409
+ int ret = bdecode (b, b + sizeof (b), e, ec, &pos);
1410
+ TEST_EQUAL (ret, -1 );
1411
+ TEST_EQUAL (pos, 2 );
1412
+ }
1413
+
1398
1414
// test switch_underlying_buffer
1399
1415
TORRENT_TEST (switch_buffer)
1400
1416
{
0 commit comments