Fixed an assert() exposed by fuzzing. Now, instead of assert when an invalid

instruction encoding is encountered, we just return a NULL ARMBasicMCBuilder
instance and the client just returns false to indicate disassembly error.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101201 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Johnny Chen
2010-04-14 01:17:37 +00:00
parent 07b3a041b4
commit efcdac0c41
2 changed files with 15 additions and 10 deletions

View File

@ -3257,6 +3257,9 @@ ARMBasicMCBuilder::ARMBasicMCBuilder(unsigned opc, ARMFormat format,
/// are responsible for freeing up of the allocated memory. Cacheing can be
/// performed by the API clients to improve performance.
ARMBasicMCBuilder *llvm::CreateMCBuilder(unsigned Opcode, ARMFormat Format) {
// For "Unknown format", fail by returning a NULL pointer.
if ((unsigned)Format >= (array_lengthof(FuncPtrs) - 1))
return 0;
return new ARMBasicMCBuilder(Opcode, Format,
ARMInsts[Opcode].getNumOperands());