make IOBuf::gather() safe
[folly.git] / folly / io / test / IOBufTest.cpp
index 5fc86644b7a8f84a7105374074bceec6e85ff8ba..baab1c854e0b6e02177f38f391819aff3ee8ca8b 100644 (file)
@@ -486,6 +486,8 @@ TEST(IOBuf, Chaining) {
   EXPECT_EQ(0, arrayBufFreeCount);
 
   // Buffer lengths: 1500 20 1234 900 321
+  // Attempting to gather more data than available should fail
+  EXPECT_THROW(chainClone->gather(4000), std::overflow_error);
   // Coalesce the first 3 buffers
   chainClone->gather(1521);
   EXPECT_EQ(3, chainClone->countChainElements());