]> granicus.if.org Git - yasm/commitdiff
* expr.c (expr_level_op): Fix corruption with certain types of complex
authorPeter Johnson <peter@tortall.net>
Wed, 7 Sep 2005 03:53:38 +0000 (03:53 -0000)
committerPeter Johnson <peter@tortall.net>
Wed, 7 Sep 2005 03:53:38 +0000 (03:53 -0000)
expressions by adjusting level_numterms if expr_simplify_identity changes
fold_numterms.

Reported by: Brian Gladman <brg@gladman.plus.com>

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

libyasm/expr.c

index cd53c6b69bac8a30aaed19d4067d45f51a493594..78aa072d042a4ab4aa6af3d69aa38027304a61f0 100644 (file)
@@ -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;
     }