Skip to content

Commit 13986c4

Browse files
committed
istream/dechunk: remove DechunkInputAction::DESTROYED
This eliminates a use-after-free bug in DechunkIstream::InvokeDechunkEnd() and eliminates an illegal state in DechunkIstream::_ConsumeBucketList() because that method is not allowed to destroy the DechunkIstream object.
1 parent cb81be4 commit 13986c4

3 files changed

Lines changed: 0 additions & 32 deletions

File tree

src/istream/DechunkIstream.cxx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,6 @@ DechunkIstream::InvokeDechunkEnd() noexcept
249249
ClearInput();
250250
break;
251251

252-
case DechunkHandler::DechunkInputAction::DESTROYED:
253-
ClearInput();
254-
break;
255-
256252
case DechunkHandler::DechunkInputAction::CLOSE:
257253
CloseInput();
258254
break;
@@ -405,7 +401,6 @@ DechunkIstream::OnData(std::span<const std::byte> src) noexcept
405401
instead of 0 */
406402
break;
407403

408-
case DechunkHandler::DechunkInputAction::DESTROYED:
409404
case DechunkHandler::DechunkInputAction::CLOSE:
410405
return 0;
411406
}

src/istream/DechunkIstream.hxx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ public:
2929
* Close the #DechunkIstream.
3030
*/
3131
CLOSE,
32-
33-
/**
34-
* The method has destroyed the #DechunkIstream.
35-
*/
36-
DESTROYED,
3732
};
3833

3934
/**

test/istream/TestDechunkIstream.cxx

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ struct MyDechunkHandler final : DechunkHandler {
4141
assert(state == State::END_SEEN);
4242
state = State::END;
4343

44-
if (action == DechunkInputAction::DESTROYED)
45-
input->Close();
46-
4744
return action;
4845
}
4946
};
@@ -146,7 +143,6 @@ TestAction(EventLoop &event_loop, struct pool &pool,
146143
MyDechunkHandler dechunk_handler{action};
147144

148145
switch (action) {
149-
case DechunkHandler::DechunkInputAction::DESTROYED:
150146
case DechunkHandler::DechunkInputAction::ABANDON:
151147
/* this kludge extracts a pointer to the input */
152148
dechunk_handler.input = input.Steal();
@@ -236,21 +232,3 @@ TEST(DechunkIstream, CloseActionBuckets2)
236232
{
237233
TestAction(DechunkHandler::DechunkInputAction::CLOSE, true, true);
238234
}
239-
240-
/**
241-
* Test DechunkInputAction::DESTROYED.
242-
*/
243-
TEST(DechunkIstream, DestroyedAction)
244-
{
245-
TestAction(DechunkHandler::DechunkInputAction::DESTROYED, false);
246-
}
247-
248-
TEST(DechunkIstream, DestroyedActionBuckets)
249-
{
250-
TestAction(DechunkHandler::DechunkInputAction::DESTROYED, true);
251-
}
252-
253-
TEST(DechunkIstream, DestroyedActionBuckets2)
254-
{
255-
TestAction(DechunkHandler::DechunkInputAction::DESTROYED, true, true);
256-
}

0 commit comments

Comments
 (0)