Merge pull request #11187 from Mic92/diff-closure-fix

diff-closures: fix a use after free
This commit is contained in:
Robert Hensing 2024-07-27 00:52:38 +02:00 committed by GitHub
commit 88e8c9017a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -25,15 +25,17 @@ GroupedPaths getClosureInfo(ref<Store> store, const StorePath & toplevel)
GroupedPaths groupedPaths;
for (auto & path : closure) {
for (auto const & path : closure) {
/* Strip the output name. Unfortunately this is ambiguous (we
can't distinguish between output names like "bin" and
version suffixes like "unstable"). */
static std::regex regex("(.*)-([a-z]+|lib32|lib64)");
std::smatch match;
std::string name(path.name());
std::cmatch match;
std::string name{path.name()};
std::string_view const origName = path.name();
std::string outputName;
if (std::regex_match(name, match, regex)) {
if (std::regex_match(origName.begin(), origName.end(), match, regex)) {
name = match[1];
outputName = match[2];
}