From: Fangrui Song Date: Thu, 30 May 2019 08:03:02 +0000 (+0000) Subject: asm goto: fix out-of-bounds read of Constraints after rC362045 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a250e2cd858f79dfedeac06dde0408d49d37eed5;p=clang 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); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@362067 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseStmtAsm.cpp b/lib/Parse/ParseStmtAsm.cpp index 75f3ac396e..e1c48da5f2 100644 --- a/lib/Parse/ParseStmtAsm.cpp +++ b/lib/Parse/ParseStmtAsm.cpp @@ -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))