Commit cf5b2228 authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook Github Bot

Fix potential use after move in window

Summary:
The lambda that gets the ctx moved in can be created before the via call.

(Note: this ignores all push blocking failures!)

Reviewed By: spalamarchuk

Differential Revision: D13009656

fbshipit-source-id: 1c89905e544adc829124277465c32958a3489845
parent 07f3b3df
......@@ -1826,9 +1826,11 @@ window(Executor::KeepAlive<> executor, Collection input, F func, size_t n) {
static void spawn(std::shared_ptr<WindowContext> ctx) {
size_t i = ctx->i.fetch_add(1, std::memory_order_relaxed);
if (i < ctx->input.size()) {
makeSemiFutureWith([&] { return ctx->func(std::move(ctx->input[i])); })
.via(ctx->executor.get())
.setCallback_([ctx = std::move(ctx), i](Try<Result>&& t) mutable {
auto fut = makeSemiFutureWith(
[&] { return ctx->func(std::move(ctx->input[i])); })
.via(ctx->executor.get());
fut.setCallback_([ctx = std::move(ctx), i](Try<Result>&& t) mutable {
ctx->promises[i].setTry(std::move(t));
// Chain another future onto this one
spawn(std::move(ctx));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment