[demangler] return early if conditional expr parsing failed

This should fix some bugs found by oss-fuzz.

llvm-svn: 324203
This commit is contained in:
Erik Pilkington 2018-02-05 02:34:41 +00:00
parent 0398ccd0c9
commit 0923542c61
1 changed files with 7 additions and 2 deletions

View File

@ -2589,10 +2589,15 @@ Node *Db::parseExpr() {
if (First[1] == 'u') {
First += 2;
Node *Cond = parseExpr();
if (Cond == nullptr)
return nullptr;
Node *LHS = parseExpr();
if (LHS == nullptr)
return nullptr;
Node *RHS = parseExpr();
if (Cond && LHS && RHS)
return make<ConditionalExpr>(Cond, LHS, RHS);
if (RHS == nullptr)
return nullptr;
return make<ConditionalExpr>(Cond, LHS, RHS);
}
return nullptr;
case 'r':