Skip to content

Commit

Permalink
Fix use-after-free in WTCallback
Browse files Browse the repository at this point in the history
Summary: `rBase` refers to `self->base_` on destruction, so we need to hold a reference to `self` for the whole function.

Reviewed By: agelun

Differential Revision: D49453402

fbshipit-source-id: 9259bcc15926244fa143c511ec73dfea29919ca2
  • Loading branch information
ot authored and facebook-github-bot committed Sep 20, 2023
1 parent bd6873b commit acd184f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion folly/futures/WTCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ struct WTCallback : public TBase::Callback {
}

(*rBase)->runInEventBaseThreadAlwaysEnqueue(
[self = std::move(self), ew = std::move(ew)]() mutable {
[self, ew = std::move(ew)]() mutable {
self->cancelTimeout();
// Don't need Promise anymore, break the circular reference
auto promise = self->stealPromise();
Expand Down

0 comments on commit acd184f

Please sign in to comment.