Skip to content

Commit bf6eb51

Browse files
committed
fix instruction length parsing
1 parent 5c1bf57 commit bf6eb51

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/assembly_scanner.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "assembly_scanner.hh"
22
#include <cinttypes>
3+
#include <cstring>
34
#include <iostream>
45
#include <set>
56

@@ -112,6 +113,10 @@ NONNULL_PTR(const std::vector<NONNULL_PTR(std::vector<instruction>)>) assembly_s
112113
cerr << "Instruction too short: " << curr_line << endl;
113114
exit(EXIT_FAILURE);
114115
}
116+
if (curr_line.size() > 3 && !strchr(WHITESPACE, curr_line[3])) {
117+
cerr << "Instruction too long: " << curr_line << endl;
118+
exit(EXIT_FAILURE);
119+
}
115120

116121
string instruction_name = curr_line.substr(0, 3);
117122
instruction::operation opcode = assembly_scanner::opcode_for_name(instruction_name);

0 commit comments

Comments
 (0)