]> granicus.if.org Git - yasm/commitdiff
Make negative times value an error case.
authorPeter Johnson <peter@tortall.net>
Sun, 30 Oct 2005 06:15:15 +0000 (06:15 -0000)
committerPeter Johnson <peter@tortall.net>
Sun, 30 Oct 2005 06:15:15 +0000 (06:15 -0000)
* bytecode.c (yasm_bc_resolve, yasm_bc_tobytes): Look for negative multiple.

* timesover-err.asm: New testcase for this.

Reported by: Stefan <SMarF@gmx.de>

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

libyasm/bytecode.c
libyasm/tests/Makefile.inc
libyasm/tests/timesover-err.asm [new file with mode: 0644]
libyasm/tests/timesover-err.errwarn [new file with mode: 0644]

index 1abf415cb313d699c3d332dbdd7309f8c099bec4..0b120f1cb7076224c5f90360c5a20ebc83980b7a 100644 (file)
@@ -1344,8 +1344,12 @@ yasm_bc_resolve(yasm_bytecode *bc, int save,
                    N_("expression must not contain floating point value"));
                retval |= YASM_BC_RESOLVE_ERROR;
            }
-       } else
-           bc->len *= yasm_intnum_get_uint(num);
+       } else {
+           if (yasm_intnum_sign(num) >= 0)
+               bc->len *= yasm_intnum_get_uint(num);
+           else
+               retval |= YASM_BC_RESOLVE_ERROR;
+       }
        yasm_expr_destroy(temp);
     }
 
@@ -1374,6 +1378,11 @@ yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize,
        if (!num)
            yasm_internal_error(
                N_("could not determine multiple in bc_tobytes"));
+       if (yasm_intnum_sign(num) < 0) {
+           yasm__error(bc->line, N_("multiple is negative"));
+           *bufsize = 0;
+           return NULL;
+       }
        *multiple = yasm_intnum_get_uint(num);
        if (*multiple == 0) {
            *bufsize = 0;
index 634bbbb5d70e39a3595b13802897902407c7a751..0594c1cf189eb869fc38237b7110921276f89f72 100644 (file)
@@ -14,6 +14,8 @@ EXTRA_DIST += libyasm/tests/duplabel-err.errwarn
 EXTRA_DIST += libyasm/tests/incbin.asm
 EXTRA_DIST += libyasm/tests/incbin.errwarn
 EXTRA_DIST += libyasm/tests/incbin.hex
+EXTRA_DIST += libyasm/tests/timesover-err.asm
+EXTRA_DIST += libyasm/tests/timesover-err.errwarn
 EXTRA_DIST += libyasm/tests/unary.asm
 EXTRA_DIST += libyasm/tests/unary.errwarn
 EXTRA_DIST += libyasm/tests/unary.hex
diff --git a/libyasm/tests/timesover-err.asm b/libyasm/tests/timesover-err.asm
new file mode 100644 (file)
index 0000000..6b3b7f9
--- /dev/null
@@ -0,0 +1,2 @@
+times 512 db 0
+times 01FEh-($-$$) db 0
diff --git a/libyasm/tests/timesover-err.errwarn b/libyasm/tests/timesover-err.errwarn
new file mode 100644 (file)
index 0000000..c972a1d
--- /dev/null
@@ -0,0 +1 @@
+-:2: multiple is negative