Skip to content

Commit

Permalink
Fix a segfault in the git fetcher
Browse files Browse the repository at this point in the history
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
  • Loading branch information
thufschmitt committed May 27, 2022
1 parent ec07a70 commit 027fd45
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/libfetchers/git.cc
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,10 @@ struct GitInputScheme : InputScheme
}
}

const Attrs unlockedAttrs({
Attrs unlockedAttrs({
{"type", cacheType},
{"name", name},
{"url", actualUrl},
{"ref", *input.getRef()},
});

Path repoDir;
Expand All @@ -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())
Expand All @@ -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)) {
Expand Down

0 comments on commit 027fd45

Please sign in to comment.