aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-09-15 03:50:11 +0000
committerChris Lattner <sabre@nondot.org>2010-09-15 03:50:11 +0000
commitf884012c93578912556de6ab89ecebab79b4ee31 (patch)
treef958a7656cef298e84ac04cb1f7412b28134f340
parentee9ca07e7f88ba100c56e2171009e158352026c8 (diff)
Diagnose invalid instructions like "incl" with "too few operands for instruction"
instead of crashing. This fixes: rdar://8431815 - crash when invalid operand is one that isn't present git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113921 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/X86/AsmParser/X86AsmParser.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp
index dae7d1298e..5052931340 100644
--- a/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -1066,12 +1066,14 @@ X86ATTAsmParser::MatchInstruction(SMLoc IDLoc,
// Recover location info for the operand if we know which was the problem.
SMLoc ErrorLoc = IDLoc;
if (OrigErrorInfo != ~0U) {
+ if (OrigErrorInfo >= Operands.size())
+ return Error(IDLoc, "too few operands for instruction");
+
ErrorLoc = ((X86Operand*)Operands[OrigErrorInfo])->getStartLoc();
if (ErrorLoc == SMLoc()) ErrorLoc = IDLoc;
}
- Error(ErrorLoc, "invalid operand for instruction");
- return true;
+ return Error(ErrorLoc, "invalid operand for instruction");
}
// If one instruction matched with a missing feature, report this as a