commit 5807e22fefaddbc71d6d610feb7aa524004eb694
parent 6799b5f78e99c416909f4aa215f41ac84a0c459e
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date: Sat, 23 Oct 2021 23:15:07 +0100
Fixed corruption in ff00-ffff, improved checks for | and $, thanks karolbelina!
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/uxnasm.c b/src/uxnasm.c
@@ -12,7 +12,7 @@ WITH REGARD TO THIS SOFTWARE.
*/
#define TRIM 0x0100
-#define LENGTH 0x10000 - TRIM
+#define LENGTH 0x10000
typedef unsigned char Uint8;
typedef signed char Sint8;
@@ -366,11 +366,13 @@ pass2(FILE *f)
if(skipblock(w, &ccmnt, '(', ')')) continue;
if(skipblock(w, &cmacr, '{', '}')) continue;
if(w[0] == '|') {
- if(p.length && shex(w + 1) < p.ptr)
+ if(p.length && (Uint16)shex(w + 1) < p.ptr)
return error("Pass 2 - Memory overwrite", w);
p.ptr = shex(w + 1);
continue;
} else if(w[0] == '$') {
+ if(p.length && (Uint16)(p.ptr + shex(w + 1)) < p.ptr)
+ return error("Pass 2 - Memory overwrite", w);
p.ptr += shex(w + 1);
continue;
} else if(w[0] == '@') {