forked from lix-project/lix
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:
parent
1ffb26311b
commit
2e5096e4f0
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue