mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 16:26:18 +02:00
* Prevent a potential memory corruption problem if an ATerm garbage
collection happens during fixAttrs().
This commit is contained in:
parent
158aa89317
commit
e14e2399ed
1 changed files with 7 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue