From 5807e22fefaddbc71d6d610feb7aa524004eb694 Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Sat, 23 Oct 2021 23:15:07 +0100 Subject: [PATCH] Fixed corruption in ff00-ffff, improved checks for | and $, thanks karolbelina! --- src/uxnasm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/uxnasm.c b/src/uxnasm.c index 37d607a..311d273 100644 --- 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] == '@') {