Merge pull request #6489 from alexshpilkin/fix-6488

nix: Add forgotten null check in AttrCursor::getListOfStrings()
This commit is contained in:
Eelco Dolstra 2022-05-05 16:16:56 +02:00 committed by GitHub
commit f4102de84b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -648,7 +648,8 @@ std::vector<std::string> AttrCursor::getListOfStrings()
for (auto & elem : v.listItems()) for (auto & elem : v.listItems())
res.push_back(std::string(root->state.forceStringNoCtx(*elem))); 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; return res;
} }

View file

@ -56,6 +56,13 @@ nix build -f multiple-outputs.nix --json 'e^*' --no-link | jq --exit-status '
(.outputs | keys == ["a", "b", "c"])) (.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 () { testNormalization () {
clearStore clearStore
outPath=$(nix-build ./simple.nix --no-out-link) outPath=$(nix-build ./simple.nix --no-out-link)