aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéophane Hufschmitt <theophane.hufschmitt@tweag.io>2022-05-27 16:15:28 +0200
committerThéophane Hufschmitt <theophane.hufschmitt@tweag.io>2022-05-27 16:15:28 +0200
commit027fd45230b74c67e65d06e7073c04b62c60eb4e (patch)
tree6dc247147c01a961a792a94605c78af917d53274
parentec07a70979a86cc436de7e46e03789b4606d25ab (diff)
Fix a segfault in the git fetcher
The git fetcher code used to dereference the (potentially empty) `ref` input attribute. This was magically working, probably because the compiler somehow outsmarted us, but is now blowing up with newer nixpkgs versions. Fix that by not trying to access this field while we don't know for sure that it has been defined. Fix #6554
-rw-r--r--src/libfetchers/git.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libfetchers/git.cc b/src/libfetchers/git.cc
index a71bff76f..9cbd39247 100644
--- a/src/libfetchers/git.cc
+++ b/src/libfetchers/git.cc
@@ -449,11 +449,10 @@ struct GitInputScheme : InputScheme
}
}
- const Attrs unlockedAttrs({
+ Attrs unlockedAttrs({
{"type", cacheType},
{"name", name},
{"url", actualUrl},
- {"ref", *input.getRef()},
});
Path repoDir;
@@ -466,6 +465,7 @@ struct GitInputScheme : InputScheme
head = "master";
}
input.attrs.insert_or_assign("ref", *head);
+ unlockedAttrs.insert_or_assign("ref", *head);
}
if (!input.getRev())
@@ -482,6 +482,7 @@ struct GitInputScheme : InputScheme
head = "master";
}
input.attrs.insert_or_assign("ref", *head);
+ unlockedAttrs.insert_or_assign("ref", *head);
}
if (auto res = getCache()->lookup(store, unlockedAttrs)) {