Skip to content

Commit ee1021c

Browse files
generatedunixname89002005232357meta-codesync[bot]
authored andcommitted
Revert D116669664
Summary: This diff reverts D116669664 (The context such as a Sandcastle job, Task, SEV, etc. was not provided.) Depends on D116669664 Differential Revision: D116857476 fbshipit-source-id: 0a259d48a9e2ad1931bf4eabb4833b7ab76978bb
1 parent fa9032a commit ee1021c

2 files changed

Lines changed: 1 addition & 21 deletions

File tree

third-party/folly/src/folly/io/IOBuf.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -860,11 +860,7 @@ IOBuf IOBuf::cloneCoalescedAsValueWithHeadroomTailroom(
860860

861861
// Coalesce into newBuf
862862
const std::size_t newLength = computeChainDataLength();
863-
std::size_t newCapacity = 0;
864-
if (!checked_add(&newCapacity, newLength, newHeadroom, newTailroom) ||
865-
newCapacity > kMaxIOBufSize) {
866-
throw_exception<std::bad_alloc>();
867-
}
863+
const std::size_t newCapacity = newLength + newHeadroom + newTailroom;
868864
IOBuf newBuf{CREATE, newCapacity};
869865
newBuf.advance(newHeadroom);
870866

third-party/folly/src/folly/io/test/IOBufTest.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,22 +1576,6 @@ TEST(IOBuf, CoalesceEmptyBuffers) {
15761576
EXPECT_TRUE(ByteRange(StringPiece("hello")) == br);
15771577
}
15781578

1579-
// cloneCoalescedAsValueWithHeadroomTailroom (and the unique_ptr wrapper that
1580-
// forwards to it) must throw std::bad_alloc when the coalesced capacity
1581-
// overflows size_t rather than wrapping around to an undersized buffer.
1582-
TEST(IOBuf, CloneCoalescedCapacityOverflow) {
1583-
auto head = fromStr("hello");
1584-
head->insertAfterThisOne(fromStr("world"));
1585-
ASSERT_TRUE(head->isChained());
1586-
1587-
constexpr auto kMax = std::numeric_limits<std::size_t>::max();
1588-
EXPECT_THROW(
1589-
head->cloneCoalescedWithHeadroomTailroom(kMax, kMax), std::bad_alloc);
1590-
EXPECT_THROW(
1591-
head->cloneCoalescedAsValueWithHeadroomTailroom(kMax, kMax),
1592-
std::bad_alloc);
1593-
}
1594-
15951579
TEST(IOBuf, CloneCoalescedChain) {
15961580
auto b = IOBuf::createChain(1000, 100);
15971581
b->advance(10);

0 commit comments

Comments
 (0)