commit c701b95541c50ad3798eeb865254ceecb88706ce
parent 4464b1ec564adf7edf74cede0672470870f84015
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date: Mon, 13 Mar 2023 06:04:33 +0000
Detect stack overflows with greater than 255 bytes.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/uxn.c b/src/uxn.c
@@ -28,7 +28,7 @@ WITH REGARD TO THIS SOFTWARE.
*/
#define HALT(c) { return uxn_halt(u, ins, (c), pc - 1); }
-#define SET(mul, add) { if(mul > s->ptr) HALT(1) s->ptr += k * mul + add; if(s->ptr > 254) HALT(2) }
+#define SET(mul, add) { if(mul > s->ptr) HALT(1) tmp = s->ptr + k * mul + add; if(tmp > 254) HALT(2) s->ptr = tmp; }
#define PUT(o, v) { s->dat[s->ptr - 1 - (o)] = (v); }
#define PUT2(o, v) { tmp = (v); s->dat[s->ptr - o - 2] = tmp >> 8; s->dat[s->ptr - o - 1] = tmp; }
#define PUSH(stack, v) { if(s->ptr > 254) HALT(2) stack->dat[stack->ptr++] = (v); }