diff options
Diffstat (limited to 'libcpu/i386_disasm.c')
| -rw-r--r-- | libcpu/i386_disasm.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libcpu/i386_disasm.c b/libcpu/i386_disasm.c index a7e03f95..4422ffa2 100644 --- a/libcpu/i386_disasm.c +++ b/libcpu/i386_disasm.c @@ -610,7 +610,9 @@ i386_disasm (Ebl *ebl __attribute__((unused)), /* Account for displacement. */ if ((modrm & 0xc7) == 5 || (modrm & 0xc0) == 0x80 - || ((modrm & 0xc7) == 0x4 && (codep[0] & 0x7) == 0x5)) + || ((modrm & 0xc7) == 0x4 + && param_start < end + && (codep[0] & 0x7) == 0x5)) param_start += 4; else if ((modrm & 0xc0) == 0x40) param_start += 1; @@ -821,7 +823,8 @@ i386_disasm (Ebl *ebl __attribute__((unused)), } FALLTHROUGH; default: - assert (! "INVALID not handled"); + str = "INVALID not handled"; + break; } } else @@ -1030,7 +1033,7 @@ i386_disasm (Ebl *ebl __attribute__((unused)), string_end_idx = bufcnt; } else - bufcnt = string_end_idx; + start_idx = bufcnt = string_end_idx; break; case 'e': @@ -1124,8 +1127,9 @@ i386_disasm (Ebl *ebl __attribute__((unused)), /* Invalid (or at least unhandled) opcode. */ if (prefixes != 0) goto print_prefix; - assert (*startp == data); - ++data; + /* Make sure we get past the unrecognized opcode if we haven't yet. */ + if (*startp == data) + ++data; ADD_STRING ("(bad)"); addr += data - begin; |
