[llvm] r246774 - Fix SEGV in InlineAsm::ConstraintInfo::Parse.

Karl Schimpf via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 3 08:41:37 PDT 2015


Author: kschimpf
Date: Thu Sep  3 10:41:37 2015
New Revision: 246774

URL: http://llvm.org/viewvc/llvm-project?rev=246774&view=rev
Log:
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

Added:
    llvm/trunk/test/Assembler/invalid-inline-constraint.ll
Modified:
    llvm/trunk/lib/IR/InlineAsm.cpp

Modified: llvm/trunk/lib/IR/InlineAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/InlineAsm.cpp?rev=246774&r1=246773&r2=246774&view=diff
==============================================================================
--- llvm/trunk/lib/IR/InlineAsm.cpp (original)
+++ llvm/trunk/lib/IR/InlineAsm.cpp Thu Sep  3 10:41:37 2015
@@ -159,7 +159,8 @@ bool InlineAsm::ConstraintInfo::Parse(St
       // 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];

Added: llvm/trunk/test/Assembler/invalid-inline-constraint.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-inline-constraint.ll?rev=246774&view=auto
==============================================================================
Binary files llvm/trunk/test/Assembler/invalid-inline-constraint.ll (added) and llvm/trunk/test/Assembler/invalid-inline-constraint.ll Thu Sep  3 10:41:37 2015 differ




More information about the llvm-commits mailing list