diff options
author | Yorick van Pelt <yorick@yorickvanpelt.nl> | 2023-08-11 12:00:31 +0200 |
---|---|---|
committer | Yorick van Pelt <yorick@yorickvanpelt.nl> | 2023-08-11 12:00:31 +0200 |
commit | 2e5096e4f0959cb2974a17fe50ad5ad891b2384f (patch) | |
tree | 3c5d6feb6263a5b7b6c1e46c9fe13b9802207522 /src/libstore/filetransfer.cc | |
parent | 1ffb26311b5d74e9f607ec31bee6c17bbae6fdae (diff) |
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.
Diffstat (limited to 'src/libstore/filetransfer.cc')
-rw-r--r-- | src/libstore/filetransfer.cc | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc index 38b691279..a283af5a2 100644 --- a/src/libstore/filetransfer.cc +++ b/src/libstore/filetransfer.cc @@ -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(); } |