From ac6ceea7641d6c19c71079e22b03b4c1519c0c94 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 1 Apr 2014 17:04:38 +0200 Subject: [PATCH] Fix potential segfault The newEnv variable was accessed (via the dynamicEnv) pointer after it had gone out of scope. Fixes #234. --- src/libexpr/nixexpr.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc index 9f0bc2630..bca2b7913 100644 --- a/src/libexpr/nixexpr.cc +++ b/src/libexpr/nixexpr.cc @@ -242,9 +242,10 @@ void ExprOpHasAttr::bindVars(const StaticEnv & env) void ExprAttrs::bindVars(const StaticEnv & env) { - const StaticEnv *dynamicEnv = &env; + const StaticEnv * dynamicEnv = &env; + StaticEnv newEnv(false, &env); + if (recursive) { - StaticEnv newEnv(false, &env); dynamicEnv = &newEnv; unsigned int displ = 0;