]> granicus.if.org Git - yasm/commitdiff
Fix memory leaks in %IF*, %ELIF*, and %UNDEF.
authorPeter Johnson <peter@tortall.net>
Mon, 18 Sep 2006 05:22:11 +0000 (05:22 -0000)
committerPeter Johnson <peter@tortall.net>
Mon, 18 Sep 2006 05:22:11 +0000 (05:22 -0000)
NASM SF Bug #852464.
Patch by: nasm64developer@yahoo.com

svn path=/trunk/yasm/; revision=1620

modules/preprocs/nasm/nasm-pp.c

index e41cd93feb006655ad5668d5bc3ad3b89e19ed50..518d96d69735d8724cc0b9d6647d34d9e535de41 100644 (file)
@@ -2270,9 +2270,9 @@ do_directive(Token * tline)
            {
                j = if_condition(tline->next, i);
                tline->next = NULL;     /* it got freed */
-               free_tlist(origline);
                j = j < 0 ? COND_NEVER : j ? COND_IF_TRUE : COND_IF_FALSE;
            }
+           free_tlist(origline);
            cond = nasm_malloc(sizeof(Cond));
            cond->next = istk->conds;
            cond->state = j;
@@ -2311,12 +2311,12 @@ do_directive(Token * tline)
                 * the normal invocation of expand_mmac_params().  Therefore,
                 * we have to do it explicitly here.
                 */
-                j = if_condition(expand_mmac_params(tline->next), i);
-                tline->next = NULL; /* it got freed */
-               free_tlist(origline);
+               j = if_condition(expand_mmac_params(tline->next), i);
+               tline->next = NULL; /* it got freed */
                istk->conds->state =
                        j < 0 ? COND_NEVER : j ? COND_IF_TRUE : COND_IF_FALSE;
            }
+           free_tlist(origline);
            return DIRECTIVE_FOUND;
 
        case PP_ELSE:
@@ -2801,8 +2801,6 @@ do_directive(Token * tline)
                smhead = &ctx->localmac;
 
            mname = tline->text;
-           last = tline;
-           last->next = NULL;
 
            /*
             * We now have a macro name... go hunt for it.