1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 10:41:16 +02:00

Don't use 'callback' object that we may have moved out of

(cherry picked from commit fa6e10ea6a)
This commit is contained in:
Eelco Dolstra 2025-05-23 23:33:59 +02:00 committed by Mergify
parent c4813b8cbc
commit acc3cd460d

View file

@ -176,13 +176,13 @@ protected:
void getFile(const std::string & path, void getFile(const std::string & path,
Callback<std::optional<std::string>> callback) noexcept override Callback<std::optional<std::string>> callback) noexcept override
{ {
auto callbackPtr = std::make_shared<decltype(callback)>(std::move(callback));
try { try {
checkEnabled(); checkEnabled();
auto request(makeRequest(path)); auto request(makeRequest(path));
auto callbackPtr = std::make_shared<decltype(callback)>(std::move(callback));
getFileTransfer()->enqueueFileTransfer(request, getFileTransfer()->enqueueFileTransfer(request,
{[callbackPtr, this](std::future<FileTransferResult> result) { {[callbackPtr, this](std::future<FileTransferResult> result) {
try { try {
@ -198,7 +198,7 @@ protected:
}}); }});
} catch (...) { } catch (...) {
callback.rethrow(); callbackPtr->rethrow();
return; return;
} }
} }