mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 23:36:16 +02:00
Avoid accessing uninitialized settings in own init (#11117)
The default value for the setting was evaluated by calling a method on the object _being currently constructed_, so we were using it before all fields were initialized. This has been fixed by making the called method static, and not using the previously used fields at all. But functionality hasn't changed! The fields were usually always zero (by chance?) anyway, meaning the conditional path was always taken. Thus the current logic has been kept, the code simplified, and UB removed. This was found with the helper of UBSan.
This commit is contained in:
parent
b230c01f73
commit
464e5925cb
2 changed files with 5 additions and 7 deletions
|
@ -56,7 +56,7 @@ EvalSettings::EvalSettings(bool & readOnlyMode, EvalSettings::LookupPathHooks lo
|
|||
builtinsAbortOnWarn = true;
|
||||
}
|
||||
|
||||
Strings EvalSettings::getDefaultNixPath() const
|
||||
Strings EvalSettings::getDefaultNixPath()
|
||||
{
|
||||
Strings res;
|
||||
auto add = [&](const Path & p, const std::string & s = std::string()) {
|
||||
|
@ -69,11 +69,9 @@ Strings EvalSettings::getDefaultNixPath() const
|
|||
}
|
||||
};
|
||||
|
||||
if (!restrictEval && !pureEval) {
|
||||
add(getNixDefExpr() + "/channels");
|
||||
add(rootChannelsDir() + "/nixpkgs", "nixpkgs");
|
||||
add(rootChannelsDir());
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ struct EvalSettings : Config
|
|||
|
||||
bool & readOnlyMode;
|
||||
|
||||
Strings getDefaultNixPath() const;
|
||||
static Strings getDefaultNixPath();
|
||||
|
||||
static bool isPseudoUrl(std::string_view s);
|
||||
|
||||
|
|
Loading…
Reference in a new issue