FileTransfer::download: fix use-after-move

std::move(state->data) and data.empty() were called in a loop, and
could run with no other threads intervening. Accessing moved objects
is undefined behavior, and could cause a crash.
This commit is contained in:
Yorick 2023-08-11 12:00:31 +02:00
parent 1ffb26311b
commit 2e5096e4f0
No known key found for this signature in database
GPG key ID: D8D3CC6D951384DE

View file

@ -863,6 +863,8 @@ void FileTransfer::download(FileTransferRequest && request, Sink & sink)
}
chunk = std::move(state->data);
/* Reset state->data after the move, since we check data.empty() */
state->data = "";
state->request.notify_one();
}