Skip to content

Commit 66191f7

Browse files
authored
Fix #12239 - crash in the x86.nz assembler ##asm (#12252)
1 parent 6d7ed26 commit 66191f7

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Diff for: libr/asm/p/asm_x86_nz.c

+9-4
Original file line numberDiff line numberDiff line change
@@ -4295,21 +4295,26 @@ LookupTable oplookup[] = {
42954295
};
42964296

42974297
static x86newTokenType getToken(const char *str, size_t *begin, size_t *end) {
4298+
if (*begin > strlen (str)) {
4299+
return TT_EOF;
4300+
}
42984301
// Skip whitespace
4299-
while (begin && isspace ((ut8)str[*begin])) {
4302+
while (begin && str[*begin] && isspace ((ut8)str[*begin])) {
43004303
++(*begin);
43014304
}
43024305

43034306
if (!str[*begin]) { // null byte
43044307
*end = *begin;
43054308
return TT_EOF;
4306-
} else if (isalpha ((ut8)str[*begin])) { // word token
4309+
}
4310+
if (isalpha ((ut8)str[*begin])) { // word token
43074311
*end = *begin;
4308-
while (end && isalnum ((ut8)str[*end])) {
4312+
while (end && str[*end] && isalnum ((ut8)str[*end])) {
43094313
++(*end);
43104314
}
43114315
return TT_WORD;
4312-
} else if (isdigit ((ut8)str[*begin])) { // number token
4316+
}
4317+
if (isdigit ((ut8)str[*begin])) { // number token
43134318
*end = *begin;
43144319
while (end && isalnum ((ut8)str[*end])) { // accept alphanumeric characters, because hex.
43154320
++(*end);

0 commit comments

Comments
 (0)