mirror of
https://github.com/Alvin-Zilverstand/bob16.git
synced 2026-11-21 12:52:59 +01:00
fix potential buffer overflow while assembling
This commit is contained in:
1 parent
93b8efc591
commit
ac4b764a34
1 file changed
+9
@@ -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++;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user