Improve unpack reserve handling

(cherry picked from commit 54229196bd11913ef0ac2c44b9f090cf619d29d8)
This commit is contained in:
Lee Clagett
2026-05-06 10:52:36 -04:00
committed by jwinterm
parent f857e2dc8c
commit da7acc3d72
3 changed files with 45 additions and 4 deletions
+14
View File
@@ -304,6 +304,20 @@ TEST(Serialization, serializes_vector_int64_as_fixed_int)
ASSERT_EQ(57, blob.size());
}
TEST(Serialization, deserializes_vector_reserve)
{
std::vector<int64_t> v;
string blob;
tools::write_varint(std::back_inserter(blob), unsigned(100));
blob.append(std::string(100, 0));
ASSERT_LT(v.capacity(), 20);
ASSERT_FALSE(serialization::parse_binary(blob, v));
ASSERT_LT(v.capacity(), 100); // could fail if lib allocates more in reserve call
}
namespace
{
template<typename T>