aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/content-address.cc
diff options
context:
space:
mode:
authorAlex Shabalin <alex.shabalin@tweag.io>2021-11-23 16:15:34 +0100
committerAlex Shabalin <alex.shabalin@tweag.io>2021-11-23 16:15:34 +0100
commitb26cb0c9ac406e03ee54aa07d36350feae8c9bfc (patch)
treee5f454e90fb176032a4f2e7e74d24d09ec77e3c0 /src/libstore/content-address.cc
parentee5f2917090a3c236f662ff0b2cec398d5ab3c9b (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.cc6
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)