From ac4b764a346e7adcbc8aec9ea6c2be5f469acc92 Mon Sep 17 00:00:00 2001 From: mrbobbyguy <84521318+somerandomviolinkid@users.noreply.github.com> Date: Sat, 5 Sep 2026 21:45:27 -0500 Subject: [PATCH] fix potential buffer overflow while assembling --- main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.c b/main.c index 6978042..2e2ce04 100644 --- a/main.c +++ b/main.c @@ -474,6 +474,10 @@ int assemble() { ram.memory[instructionCount] = 0; instructionCount++; + if (instructionCount > 0xFFFF) { + printf("Too many instructions!\n"); + return -7; + } } else if (strcmp(tokens[0], "add") == 0) { instruction += (1 << 12); @@ -915,6 +919,11 @@ int assemble() { ram.memory[instructionCount] = instruction; instructionCount++; + if (instructionCount > 0xFFFF) { + printf("Too many instructions!\n"); + return -7; + } + lineCount++; }