about summary refs log tree commit diff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-02T13·24+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-02T13·24+0200
commitc945f015de2149233c1e4fa1628f05567f3657ba (patch)
treeeb12ef25cb13ac49c2b577d2f6ff000251ad5f6d /src/libexpr/eval.cc
parent28e0742966e962f2672f5731ea3612f223bf3283 (diff)
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
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index af2bf92e3f..050991a1bf 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -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);