From: Karl Schimpf Date: Thu, 3 Sep 2015 15:41:37 +0000 (+0000) Subject: Fix SEGV in InlineAsm::ConstraintInfo::Parse. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=06bd94ca1b397e5a4bf7ebfa46ebd4b52d47f31a Fix SEGV in InlineAsm::ConstraintInfo::Parse. 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246774 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/IR/InlineAsm.cpp b/lib/IR/InlineAsm.cpp index b7309b4f67b..15d3b830b8f 100644 --- a/lib/IR/InlineAsm.cpp +++ b/lib/IR/InlineAsm.cpp @@ -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]; diff --git a/test/Assembler/invalid-inline-constraint.ll b/test/Assembler/invalid-inline-constraint.ll new file mode 100644 index 00000000000..84b2e5c87da Binary files /dev/null and b/test/Assembler/invalid-inline-constraint.ll differ