THRIFT-5716: Fix uint32_t overflow in TMemoryBuffer
diff --git a/lib/cpp/test/TMemoryBufferTest.cpp b/lib/cpp/test/TMemoryBufferTest.cpp
index 0ae4dc9..2f1aea6 100644
--- a/lib/cpp/test/TMemoryBufferTest.cpp
+++ b/lib/cpp/test/TMemoryBufferTest.cpp
@@ -385,6 +385,14 @@
BOOST_CHECK_THROW(buf.write(&small_buff[0], 1), TTransportException);
}
+BOOST_AUTO_TEST_CASE(test_buffer_overflow)
+{
+ TMemoryBuffer buf;
+ std::vector<uint8_t> small_buff(1);
+ buf.write(&small_buff[0], 1);
+ BOOST_CHECK_THROW(buf.getWritePtr(std::numeric_limits<uint32_t>::max()), TTransportException);
+}
+
BOOST_AUTO_TEST_CASE(test_memory_buffer_to_get_sizeof_objects)
{
// This is a demonstration of how to use TMemoryBuffer to determine