diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 9c3a0b3d6..2cd6c15ec 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -307,8 +307,9 @@ void Store::addMultipleToStore(
         [&](const StorePath & path) {
             checkInterrupt();
 
-            auto & [info_, source] = *infosMap.at(path);
+            auto & [info_, source_] = *infosMap.at(path);
             auto info = info_;
+            auto source = std::move(source_);
             info.ultimate = false;
 
             /* Make sure that the Source object is destroyed when