From 35c7d5d2f113b5d50bd0702bcdb81a8a0123196a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophane=20Hufschmitt?= Date: Mon, 11 Apr 2022 10:20:36 +0200 Subject: [PATCH] gc: Only track sensible paths from maps file --- src/nix-find-roots/nix-find-roots.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/nix-find-roots/nix-find-roots.cc b/src/nix-find-roots/nix-find-roots.cc index 8ceb92521..4db24b29e 100644 --- a/src/nix-find-roots/nix-find-roots.cc +++ b/src/nix-find-roots/nix-find-roots.cc @@ -234,8 +234,11 @@ void scanMapsFile(const GlobalOpts & opts, const fs::path & mapsFile, Roots & re std::string line; while (std::getline(mappedFile, line)) { auto match = std::smatch{}; - if (std::regex_match(line, match, mapRegex)) - res[fs::path(match[1])].emplace(mapsFile); + if (std::regex_match(line, match, mapRegex)) { + auto matchedPath = fs::path(match[1]); + if (isInStore(opts.storeDir, matchedPath)) + res[fs::path(match[1])].emplace(mapsFile); + } } }