nix-env: Fix segfault if -f argument is not a directory or a Nix expression
Fixes #2425.
This commit is contained in:
parent
901dfc7978
commit
52f6d541b9
1 changed files with 4 additions and 4 deletions
|
@ -150,10 +150,8 @@ static void loadSourceExpr(EvalState & state, const Path & path, Value & v)
|
||||||
if (stat(path.c_str(), &st) == -1)
|
if (stat(path.c_str(), &st) == -1)
|
||||||
throw SysError(format("getting information about '%1%'") % path);
|
throw SysError(format("getting information about '%1%'") % path);
|
||||||
|
|
||||||
if (isNixExpr(path, st)) {
|
if (isNixExpr(path, st))
|
||||||
state.evalFile(path, v);
|
state.evalFile(path, v);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The path is a directory. Put the Nix expressions in the
|
/* The path is a directory. Put the Nix expressions in the
|
||||||
directory in a set, with the file name of each expression as
|
directory in a set, with the file name of each expression as
|
||||||
|
@ -161,13 +159,15 @@ static void loadSourceExpr(EvalState & state, const Path & path, Value & v)
|
||||||
set flat, not nested, to make it easier for a user to have a
|
set flat, not nested, to make it easier for a user to have a
|
||||||
~/.nix-defexpr directory that includes some system-wide
|
~/.nix-defexpr directory that includes some system-wide
|
||||||
directory). */
|
directory). */
|
||||||
if (S_ISDIR(st.st_mode)) {
|
else if (S_ISDIR(st.st_mode)) {
|
||||||
state.mkAttrs(v, 1024);
|
state.mkAttrs(v, 1024);
|
||||||
state.mkList(*state.allocAttr(v, state.symbols.create("_combineChannels")), 0);
|
state.mkList(*state.allocAttr(v, state.symbols.create("_combineChannels")), 0);
|
||||||
StringSet attrs;
|
StringSet attrs;
|
||||||
getAllExprs(state, path, attrs, v);
|
getAllExprs(state, path, attrs, v);
|
||||||
v.attrs->sort();
|
v.attrs->sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else throw Error("path '%s' is not a directory or a Nix expression", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue