]> granicus.if.org Git - yasm/commitdiff
* x86id.re (x86_new_jmp): Fix evaluation order dependent call when creating
authorPeter Johnson <peter@tortall.net>
Wed, 13 Oct 2004 03:55:04 +0000 (03:55 -0000)
committerPeter Johnson <peter@tortall.net>
Wed, 13 Oct 2004 03:55:04 +0000 (03:55 -0000)
a FAR target expression.  The create_branch() call could be called before
the expr_copy() call; the former can (and does) delete op->data.val.  Move
the expr_copy() call to an earlier statement to force the correct
evaluation order.

Thanks to: HP TestDrive for providing the Itanium system that discovered
this bug.

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

modules/arch/x86/x86id.re

index dacf5f1dd4aec80b20c05cbe3262d6ca0e2d8935..b02702e4494fa92e0c8abbba7e48f16cdcb7d8c0 100644 (file)
@@ -1722,11 +1722,12 @@ x86_new_jmp(yasm_arch *arch, const unsigned long data[4], int num_operands,
        yasm_internal_error(N_("invalid operand conversion"));
 
     /* Far target needs to become "seg imm:imm". */
-    if ((jinfo->operands[0] & OPTM_MASK) == OPTM_Far)
+    if ((jinfo->operands[0] & OPTM_MASK) == OPTM_Far) {
+       yasm_expr *copy = yasm_expr_copy(op->data.val);
        d.target = yasm_expr_create_tree(
            yasm_expr_create_branch(YASM_EXPR_SEG, op->data.val, line),
-           YASM_EXPR_SEGOFF, yasm_expr_copy(op->data.val), line);
-    else
+           YASM_EXPR_SEGOFF, copy, line);
+    else
        d.target = op->data.val;
 
     /* Need to save jump origin for relative jumps. */