diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-12-15 16:00:46 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2022-12-15 16:02:27 +0100 |
commit | 0687e16c4afd131540181cc66136418ac1cb845c (patch) | |
tree | 71d3df010b0d863bd2014fc4407d1dc7db3ac1c6 /src/libstore | |
parent | 5d77c08858096a3d8f95735ec2227c544f5cdb9c (diff) |
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.
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/derived-path.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libstore/derived-path.cc b/src/libstore/derived-path.cc index 05c2303db..3fa5ae4f7 100644 --- a/src/libstore/derived-path.cc +++ b/src/libstore/derived-path.cc @@ -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 // able to print the output paths, so let’s do it const auto knownOutputs = store->queryPartialDerivationOutputMap(drvPath); - for (const auto& output : outputs) { + for (const auto & output : outputs) { auto knownOutput = get(knownOutputs, output); - res["outputs"][output] = (knownOutput && *knownOutput) - ? store->printStorePath(**knownOutput) - : nullptr; + if (knownOutput && *knownOutput) + res["outputs"][output] = store->printStorePath(**knownOutput); + else + res["outputs"][output] = nullptr; } return res; } |