[arm] Fail disassembly if readInstruction returns 0 bytes consumed

Without this check this condition could cause the disassembly to
recurse until all system memory is exhausted.
This commit is contained in:
Kevin Quick 2018-03-26 16:05:34 -07:00
parent 80886bd73d
commit 9e0c325400
No known key found for this signature in database
GPG Key ID: E6D7733599CC0A21

View File

@ -134,6 +134,7 @@ disassembleBlock lookupSemantics mem gs curPCAddr maxOffset = do
let off = MM.msegOffset curPCAddr
case readInstruction mem curPCAddr of
Left err -> failAt gs off curPCAddr (DecodeError err)
Right (_, 0) -> failAt gs off curPCAddr (InvalidNextPC curPCAddr curPCAddr)
Right (i, bytesRead) -> do
-- traceM ("II: " ++ show i)
let nextPCOffset = off + bytesRead