Fix segfault in nix-repl / hydra-eval-jobs

If a "with" attribute set fails to evaluate, we have to make sure its
Env record remains unchanged.  Otherwise, repeated evaluation gives a
segfault:

  nix-repl> :a with 0; { a = x; b = x; }
  Added 2 variables.

  nix-repl> a
  error: value is an integer while an attribute set was expected

  nix-repl> b
  Segmentation fault
This commit is contained in:
Eelco Dolstra 2013-10-02 15:24:45 +02:00
parent 28e0742966
commit c945f015de
1 changed files with 3 additions and 3 deletions

View File

@ -319,9 +319,9 @@ inline Value * EvalState::lookupVar(Env * env, const VarRef & var, bool noEval)
while (1) {
if (!env->haveWithAttrs) {
if (noEval) return 0;
Expr * attrs = (Expr *) env->values[0];
env->values[0] = allocValue();
evalAttrs(*env->up, attrs, *env->values[0]);
Value * v = allocValue();
evalAttrs(*env->up, (Expr *) env->values[0], *v);
env->values[0] = v;
env->haveWithAttrs = true;
}
Bindings::iterator j = env->values[0]->attrs->find(var.name);