Skip to content

Commit

Permalink
Fix SEGV in InlineAsm::ConstraintInfo::Parse.
Browse files Browse the repository at this point in the history
Summary:
Fixes bug 24646. Previous code was not checking if an index into a vector
was valid, resulting in a SEGV. Fixed by assuming the construct can't
be parsed when given this input.

Reformat and add test.

Differential Revision: http://reviews.llvm.org/D12539

llvm-svn: 246774
  • Loading branch information
KarlSchimpf committed Sep 3, 2015
1 parent 388fd5a commit f04a5d5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion llvm/lib/IR/InlineAsm.cpp
Expand Up @@ -159,7 +159,8 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str,
// If Operand N already has a matching input, reject this. An output
// can't be constrained to the same value as multiple inputs.
if (isMultipleAlternative) {
if (multipleAlternativeIndex >= ConstraintsSoFar[N].multipleAlternatives.size())
if (multipleAlternativeIndex >=
ConstraintsSoFar[N].multipleAlternatives.size())
return true;
InlineAsm::SubConstraintInfo &scInfo =
ConstraintsSoFar[N].multipleAlternatives[multipleAlternativeIndex];
Expand Down
Binary file added llvm/test/Assembler/invalid-inline-constraint.ll
Binary file not shown.

0 comments on commit f04a5d5

Please sign in to comment.