From: Peter Johnson <peter@tortall.net> Date: Wed, 13 Oct 2004 03:55:04 +0000 (-0000) Subject: * x86id.re (x86_new_jmp): Fix evaluation order dependent call when creating X-Git-Tag: v0.4.0~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=692fa844babfecaf984788ba7185d5189c63277c;p=yasm * x86id.re (x86_new_jmp): Fix evaluation order dependent call when creating 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 --- diff --git a/modules/arch/x86/x86id.re b/modules/arch/x86/x86id.re index dacf5f1d..b02702e4 100644 --- a/modules/arch/x86/x86id.re +++ b/modules/arch/x86/x86id.re @@ -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. */