summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2018-10-13 16:18:16 +0300
committerCyrill Gorcunov <gorcunov@gmail.com>2018-10-13 16:18:16 +0300
commite996d28c70d45008085322b442b44a9224308548 (patch)
treeb2f289831395162a5ac8f332535b633320ec668f
parent703e5658498222c3aa77e57fefb466d264abbe58 (diff)
downloadnasm-e996d28c70d45008085322b442b44a9224308548.tar.gz
labels: Don't nil dereference if no label provided
An equ without label may cause nil dereference | equ 0x100 Fixes 98578071b9d71ecaa2344dd9c185237c1765041e Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rw-r--r--asm/nasm.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/asm/nasm.c b/asm/nasm.c
index 0deec783..ae90b89c 100644
--- a/asm/nasm.c
+++ b/asm/nasm.c
@@ -1481,13 +1481,11 @@ static void assemble_file(const char *fname, StrList **depend_ptr)
/* forw_ref */
if (output_ins.opcode == I_EQU) {
- if (!output_ins.label)
- nasm_error(ERR_NONFATAL,
- "EQU not preceded by label");
-
- if (output_ins.operands == 1 &&
- (output_ins.oprs[0].type & IMMEDIATE) &&
- output_ins.oprs[0].wrt == NO_SEG) {
+ if (!output_ins.label) {
+ nasm_error(ERR_NONFATAL, "EQU not preceded by label");
+ } else if (output_ins.operands == 1 &&
+ (output_ins.oprs[0].type & IMMEDIATE) &&
+ output_ins.oprs[0].wrt == NO_SEG) {
define_label(output_ins.label,
output_ins.oprs[0].segment,
output_ins.oprs[0].offset, false);