From 2bfbadcbc19eeb7e059d844bcd8fd844f1c0a0ed Mon Sep 17 00:00:00 2001 From: Daniil Fukalov Date: Wed, 25 Oct 2017 12:51:32 +0000 Subject: [inlineasm] Fix crash when number of matched input constraint operands overflows signed char In a case when number of output constraint operands that has matched input operands doesn't fit to signed char, TargetLowering::ParseConstraints() can try to access ConstraintOperands (that is std::vector) with negative index. Reviewers: rampitec, arsenm Differential Review: https://reviews.llvm.org/D39125 llvm-svn: 316574 --- llvm/lib/IR/InlineAsm.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'llvm/lib/IR/InlineAsm.cpp') diff --git a/llvm/lib/IR/InlineAsm.cpp b/llvm/lib/IR/InlineAsm.cpp index ad22efdf0ef..8667d7aab58 100644 --- a/llvm/lib/IR/InlineAsm.cpp +++ b/llvm/lib/IR/InlineAsm.cpp @@ -163,6 +163,7 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str, return true; // Note that operand #n has a matching input. scInfo.MatchingInput = ConstraintsSoFar.size(); + assert(scInfo.MatchingInput >= 0); } else { if (ConstraintsSoFar[N].hasMatchingInput() && (size_t)ConstraintsSoFar[N].MatchingInput != @@ -170,6 +171,7 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str, return true; // Note that operand #n has a matching input. ConstraintsSoFar[N].MatchingInput = ConstraintsSoFar.size(); + assert(ConstraintsSoFar[N].MatchingInput >= 0); } } else if (*I == '|') { multipleAlternativeIndex++; -- cgit v1.2.3