From: Peter Johnson Date: Wed, 7 Sep 2005 03:53:38 +0000 (-0000) Subject: * expr.c (expr_level_op): Fix corruption with certain types of complex X-Git-Tag: v0.5.0rc1~153 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=df255ca25d684a5560eaa50f3655ef42822fd085;p=yasm * expr.c (expr_level_op): Fix corruption with certain types of complex expressions by adjusting level_numterms if expr_simplify_identity changes fold_numterms. Reported by: Brian Gladman svn path=/trunk/yasm/; revision=1224 --- diff --git a/libyasm/expr.c b/libyasm/expr.c index cd53c6b6..78aa072d 100644 --- a/libyasm/expr.c +++ b/libyasm/expr.c @@ -582,11 +582,15 @@ expr_level_op(/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const, o++; } - if (simplify_ident) + if (simplify_ident) { + int new_fold_numterms; /* Simplify identities and make IDENT if possible. */ - fold_numterms = expr_simplify_identity(e, fold_numterms, - first_int_term); - else if (fold_numterms == 1) + new_fold_numterms = expr_simplify_identity(e, fold_numterms, + first_int_term); + level_numterms -= fold_numterms-new_fold_numterms; + fold_numterms = new_fold_numterms; + } + if (fold_numterms == 1) e->op = YASM_EXPR_IDENT; }