asm goto: fix out-of-bounds read of Constraints after rC362045

When parsing goto labels, Names and Exprs are expanded but Constraints
is not, this may cause a out-of-bounds read later in:

// GCCAsmStmt::GCCAsmStmt
// `constraints` has only `NumExprs - NumLabels` elements
  Constraints = new (C) StringLiteral*[NumExprs];
  std::copy(constraints, constraints + NumExprs, Constraints);

llvm-svn: 362067
This commit is contained in:
Fangrui Song 2019-05-30 08:03:02 +00:00
parent bb4839d415
commit 9b8a0d7110
1 changed files with 1 additions and 0 deletions

View File

@ -846,6 +846,7 @@ StmtResult Parser::ParseAsmStatement(bool &msAsm) {
ExprResult Res =
Actions.ActOnAddrLabel(Tok.getLocation(), Tok.getLocation(), LD);
Exprs.push_back(Res.get());
Constraints.emplace_back();
NumLabels++;
ConsumeToken();
if (!TryConsumeToken(tok::comma))