Merge pull request #5636 from tweag/fix-use-after-free

Fix use after free in content-address.cc
This commit is contained in:
Eelco Dolstra 2021-11-24 12:11:00 +01:00 committed by GitHub
commit 6f4d1af971
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -120,8 +120,10 @@ ContentAddress parseContentAddress(std::string_view rawCa) {
ContentAddressMethod parseContentAddressMethod(std::string_view caMethod) ContentAddressMethod parseContentAddressMethod(std::string_view caMethod)
{ {
std::string_view asPrefix {std::string{caMethod} + ":"}; std::string asPrefix = std::string{caMethod} + ":";
return parseContentAddressMethodPrefix(asPrefix); // parseContentAddressMethodPrefix takes its argument by reference
std::string_view asPrefixView = asPrefix;
return parseContentAddressMethodPrefix(asPrefixView);
} }
std::optional<ContentAddress> parseContentAddressOpt(std::string_view rawCaOpt) std::optional<ContentAddress> parseContentAddressOpt(std::string_view rawCaOpt)