about summary refs log tree commit diff
path: root/src/libexpr/parser.y
diff options
context:
space:
mode:
authorNicolas Pierron <nicolas.b.pierron@gmail.com>2010-03-14T11·58+0000
committerNicolas Pierron <nicolas.b.pierron@gmail.com>2010-03-14T11·58+0000
commit741b7577c14911fed71b6d52d8d90e88ef2e05ef (patch)
treecabee93fbbc7c8b32b9cc485f1fab684b1d8996a /src/libexpr/parser.y
parent2fb0df83e960d6b39dd43b47cc6168cad3732746 (diff)
Merge r20344 & r20346.
Diffstat (limited to 'src/libexpr/parser.y')
-rw-r--r--src/libexpr/parser.y8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index c4afb72eac..8706ce0254 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -85,6 +85,10 @@ static Expr fixAttrs(bool recursive, ATermList as)
 {
     Tree attrs;
 
+    /* This ATermMap is needed to ensure that the `leaf' fields in the
+       Tree nodes are not garbage collected. */
+    ATermMap gcRoots;
+
     for (ATermIterator i(as); i; ++i) {
         ATermList names, attrPath; Expr src, e; ATerm name, pos;
 
@@ -95,7 +99,9 @@ static Expr fixAttrs(bool recursive, ATermList as)
                     throw ParseError(format("duplicate definition of attribute `%1%' at %2%")
                         % showAttrPath(ATmakeList1(*j)) % showPos(pos));
                 Tree & t(attrs.children[*j]);
-                t.leaf = fromScope ? makeVar(*j) : makeSelect(src, *j);
+                Expr leaf = fromScope ? makeVar(*j) : makeSelect(src, *j);
+                gcRoots.set(leaf, leaf);
+                t.leaf = leaf;
                 t.pos = pos;
                 if (recursive && fromScope) t.recursive = false;
             }