diff options
author | Alex Shabalin <alex.shabalin@tweag.io> | 2021-11-23 16:15:34 +0100 |
---|---|---|
committer | Alex Shabalin <alex.shabalin@tweag.io> | 2021-11-23 16:15:34 +0100 |
commit | b26cb0c9ac406e03ee54aa07d36350feae8c9bfc (patch) | |
tree | e5f454e90fb176032a4f2e7e74d24d09ec77e3c0 /src/libstore/content-address.cc | |
parent | ee5f2917090a3c236f662ff0b2cec398d5ab3c9b (diff) |
Fix use after free in content-address.cc
Inspired by https://github.com/NixOS/nix/pull/5599
Diffstat (limited to 'src/libstore/content-address.cc')
-rw-r--r-- | src/libstore/content-address.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libstore/content-address.cc b/src/libstore/content-address.cc index 974d1c471..cf32ccdc4 100644 --- a/src/libstore/content-address.cc +++ b/src/libstore/content-address.cc @@ -120,8 +120,10 @@ ContentAddress parseContentAddress(std::string_view rawCa) { ContentAddressMethod parseContentAddressMethod(std::string_view caMethod) { - std::string_view asPrefix {std::string{caMethod} + ":"}; - return parseContentAddressMethodPrefix(asPrefix); + std::string asPrefix = std::string{caMethod} + ":"; + // parseContentAddressMethodPrefix takes its argument by reference + std::string_view asPrefixView = asPrefix; + return parseContentAddressMethodPrefix(asPrefixView); } std::optional<ContentAddress> parseContentAddressOpt(std::string_view rawCaOpt) |