summaryrefslogtreecommitdiffstats
path: root/llvm/lib
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
commitd28452d94a639dc073a227ba4fbd5c0889317c0c (patch)
tree6ff10b10681c593cc4a9ad9bcc54a2d52e0efd56 /llvm/lib
parentc4deb923166ca8e63a9943f1e5b304404709e92a (diff)
downloadbcm5719-llvm-d28452d94a639dc073a227ba4fbd5c0889317c0c.tar.gz
bcm5719-llvm-d28452d94a639dc073a227ba4fbd5c0889317c0c.zip
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 llvm-svn: 113921
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index dae7d1298eb..50529313403 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/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
OpenPOWER on IntegriCloud