Commit 554c8541 by John Kessenich

Fix preprocessor memory leak.

parent db4cd54d
...@@ -1032,24 +1032,26 @@ int MacroExpand(int atom, yystypepp* yylvalpp, int expandUndef) ...@@ -1032,24 +1032,26 @@ int MacroExpand(int atom, yystypepp* yylvalpp, int expandUndef)
return 1; return 1;
} }
// no recursive expansions
if (sym && sym->details.mac.busy) if (sym && sym->details.mac.busy)
return 0; // no recursive expansions return 0;
// not expanding of undefined symbols
if ((! sym || sym->details.mac.undef) && ! expandUndef)
return 0;
in = (MacroInputSrc*)malloc(sizeof(*in)); in = (MacroInputSrc*)malloc(sizeof(*in));
memset(in, 0, sizeof(*in)); memset(in, 0, sizeof(*in));
in->base.line = cpp->currentInput->line; in->base.line = cpp->currentInput->line;
in->base.name = cpp->currentInput->name; in->base.name = cpp->currentInput->name;
if ((! sym || sym->details.mac.undef)) { if ((! sym || sym->details.mac.undef) && expandUndef) {
if (expandUndef) {
// push input // push input
in->base.scan = zero_scan; in->base.scan = zero_scan;
in->base.prev = cpp->currentInput; in->base.prev = cpp->currentInput;
cpp->currentInput = &in->base; cpp->currentInput = &in->base;
return -1; return -1;
} else
return 0;
} }
in->base.scan = macro_scan; in->base.scan = macro_scan;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment