nixos-option: fix potential memory leak in mapOptions

This commit is contained in:
Jörg Thalheim
2024-11-14 00:23:00 +01:00
parent 6fe4fb2b95
commit 7a8407e477
2 changed files with 1 additions and 2 deletions
-1
View File
@@ -1,5 +1,4 @@
Checks:
- -*
- bugprone-*
# don't find them too problematic
- -bugprone-easily-swappable-parameters
@@ -313,7 +313,7 @@ void mapOptions(const std::function<void(const std::string & path)> & f, Context
{
auto root = findAlongOptionPath(ctx, path);
recurse(
[f, &ctx](const std::string & path, std::variant<Value, std::exception_ptr> v) {
[&f, &ctx](const std::string & path, std::variant<Value, std::exception_ptr> v) {
const bool isOpt = std::holds_alternative<std::exception_ptr>(v) || isOption(ctx, std::get<Value>(v));
if (isOpt) {
f(path);