Skip to content

Commit

Permalink
Merge pull request #6489 from alexshpilkin/fix-6488
Browse files Browse the repository at this point in the history
nix: Add forgotten null check in AttrCursor::getListOfStrings()
  • Loading branch information
edolstra authored May 5, 2022
2 parents f2a1509 + 4c5aa85 commit f4102de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libexpr/eval-cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,8 @@ std::vector<std::string> AttrCursor::getListOfStrings()
for (auto & elem : v.listItems())
res.push_back(std::string(root->state.forceStringNoCtx(*elem)));

cachedValue = {root->db->setListOfStrings(getKey(), res), res};
if (root->db)
cachedValue = {root->db->setListOfStrings(getKey(), res), res};

return res;
}
Expand Down
7 changes: 7 additions & 0 deletions tests/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ nix build -f multiple-outputs.nix --json 'e^*' --no-link | jq --exit-status '
(.outputs | keys == ["a", "b", "c"]))
'

# Make sure that `--impure` works (regression test for https://github.com/NixOS/nix/issues/6488)
nix build --impure -f multiple-outputs.nix --json e --no-link | jq --exit-status '
(.[0] |
(.drvPath | match(".*multiple-outputs-e.drv")) and
(.outputs | keys == ["a", "b"]))
'

testNormalization () {
clearStore
outPath=$(nix-build ./simple.nix --no-out-link)
Expand Down

0 comments on commit f4102de

Please sign in to comment.