forked from lix-project/lix
Fix a crash in DerivedPath::Built::toJSON() with impure derivations
The use of 'nullptr' here didn't result in a null JSON value, but in a nullptr being cast to a string, which aborts.
This commit is contained in:
parent
5d77c08858
commit
0687e16c4a
|
@ -20,11 +20,12 @@ nlohmann::json DerivedPath::Built::toJSON(ref<Store> store) const {
|
||||||
// Fallback for the input-addressed derivation case: We expect to always be
|
// Fallback for the input-addressed derivation case: We expect to always be
|
||||||
// able to print the output paths, so let’s do it
|
// able to print the output paths, so let’s do it
|
||||||
const auto knownOutputs = store->queryPartialDerivationOutputMap(drvPath);
|
const auto knownOutputs = store->queryPartialDerivationOutputMap(drvPath);
|
||||||
for (const auto& output : outputs) {
|
for (const auto & output : outputs) {
|
||||||
auto knownOutput = get(knownOutputs, output);
|
auto knownOutput = get(knownOutputs, output);
|
||||||
res["outputs"][output] = (knownOutput && *knownOutput)
|
if (knownOutput && *knownOutput)
|
||||||
? store->printStorePath(**knownOutput)
|
res["outputs"][output] = store->printStorePath(**knownOutput);
|
||||||
: nullptr;
|
else
|
||||||
|
res["outputs"][output] = nullptr;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ clearStore
|
||||||
# Basic test of impure derivations: building one a second time should not use the previous result.
|
# Basic test of impure derivations: building one a second time should not use the previous result.
|
||||||
printf 0 > $TEST_ROOT/counter
|
printf 0 > $TEST_ROOT/counter
|
||||||
|
|
||||||
|
nix build --dry-run --json --file ./impure-derivations.nix impure.all
|
||||||
json=$(nix build -L --no-link --json --file ./impure-derivations.nix impure.all)
|
json=$(nix build -L --no-link --json --file ./impure-derivations.nix impure.all)
|
||||||
path1=$(echo $json | jq -r .[].outputs.out)
|
path1=$(echo $json | jq -r .[].outputs.out)
|
||||||
path1_stuff=$(echo $json | jq -r .[].outputs.stuff)
|
path1_stuff=$(echo $json | jq -r .[].outputs.stuff)
|
||||||
|
|
Loading…
Reference in a new issue