mirror of
https://github.com/Alvin-Zilverstand/bob16.git
synced 2026-11-27 21:57:49 +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;
|
ram.memory[instructionCount] = 0;
|
||||||
instructionCount++;
|
instructionCount++;
|
||||||
|
if (instructionCount > 0xFFFF) {
|
||||||
|
printf("Too many instructions!\n");
|
||||||
|
return -7;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (strcmp(tokens[0], "add") == 0) {
|
} else if (strcmp(tokens[0], "add") == 0) {
|
||||||
instruction += (1 << 12);
|
instruction += (1 << 12);
|
||||||
@@ -915,6 +919,11 @@ int assemble() {
|
|||||||
|
|
||||||
ram.memory[instructionCount] = instruction;
|
ram.memory[instructionCount] = instruction;
|
||||||
instructionCount++;
|
instructionCount++;
|
||||||
|
if (instructionCount > 0xFFFF) {
|
||||||
|
printf("Too many instructions!\n");
|
||||||
|
return -7;
|
||||||
|
}
|
||||||
|
|
||||||
lineCount++;
|
lineCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user