From: Karl Schimpf Date: Thu, 3 Sep 2015 15:41:34 +0000 (+0000) Subject: Fix SEGV in InlineAsm::ConstraintInfo::Parse. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=c82ddc24fd38fcd2882a7b15f1e587d4ab4b4f6a;p=oota-llvm.git Fix SEGV in InlineAsm::ConstraintInfo::Parse. 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246773 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/IR/InlineAsm.cpp b/lib/IR/InlineAsm.cpp index a181c5e834d..b7309b4f67b 100644 --- a/lib/IR/InlineAsm.cpp +++ b/lib/IR/InlineAsm.cpp @@ -159,6 +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()) + return true; InlineAsm::SubConstraintInfo &scInfo = ConstraintsSoFar[N].multipleAlternatives[multipleAlternativeIndex]; if (scInfo.MatchingInput != -1) @@ -290,4 +292,3 @@ bool InlineAsm::Verify(FunctionType *Ty, StringRef ConstStr) { if (Ty->getNumParams() != NumInputs) return false; return true; } -