Fixed a few bugs related to bounds checking and similar.
h3rald h3rald@h3rald.com
Fri, 13 Feb 2026 07:37:58 +0100
M
xywasm.c
→
xywasm.c
@@ -74,7 +74,7 @@ // Tracks whether we are inside a directive or not
static unsigned int directive = 0; // Bytecode to be written -xyw_byte data[0xffff] = {}; +xyw_byte data[0x10000] = {}; // Current write pointer xyw_word ptr = 0;@@ -708,9 +708,8 @@ }
} break; } - if (length > DIRECTIVE_CONTENT_MAX_LENGTH) + if (length >= DIRECTIVE_CONTENT_MAX_LENGTH - 1) { - token_error("Macro contents too long"); return -1; }@@ -872,7 +871,7 @@ token_column = ctx->column;
token_started = 1; } ctx->column++; - if (token_length > TOKEN_MAX_LENGTH) + if (token_length >= TOKEN_MAX_LENGTH - 1) { token_error("Token too long"); return TOKEN_END_INVALID;@@ -938,7 +937,7 @@ return TOKEN_END_INVALID;
} } ctx->column++; - if (token_length > TOKEN_MAX_LENGTH) + if (token_length >= TOKEN_MAX_LENGTH - 1) { token_error("Token too long"); return TOKEN_END_INVALID;@@ -987,7 +986,7 @@ token_column = ctx->column;
token_started = 1; } ctx->column++; - if (token_length > TOKEN_MAX_LENGTH) + if (token_length >= TOKEN_MAX_LENGTH - 1) { token_error("Token too long"); return TOKEN_END_INVALID;
M
xywrun.c
→
xywrun.c
@@ -8,7 +8,7 @@ #include "devices/clock.h"
#include "devices/file.h" #include "devices/beeper.h" -#define MEMORY_SIZE 0xffff +#define MEMORY_SIZE 0x10000 #define STACK_SIZE 0xff #define USER_MEMORY_START 0x000@@ -89,6 +89,7 @@
//// Helpers to retrieve device number and address within the device static inline int get_device(xyw_word addr) { + if (addr < DEVICE_AREA_START) return -1; return (addr - DEVICE_AREA_START) / 16; }