From 851f57effaaa8b13d345142f43dbed35e3047f23 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 30 May 2019 07:21:08 +0000 Subject: [PATCH] [AST] asm goto labels don't have constraints, don't try to copy them. Found by asan. llvm-svn: 362062 --- clang/lib/AST/Stmt.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index e9a2c58..0a4d403 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -483,9 +483,10 @@ void GCCAsmStmt::setOutputsAndInputsAndClobbers(const ASTContext &C, this->Exprs = new (C) Stmt*[NumExprs]; std::copy(Exprs, Exprs + NumExprs, this->Exprs); + unsigned NumConstraints = NumOutputs + NumInputs; C.Deallocate(this->Constraints); - this->Constraints = new (C) StringLiteral*[NumExprs]; - std::copy(Constraints, Constraints + NumExprs, this->Constraints); + this->Constraints = new (C) StringLiteral*[NumConstraints]; + std::copy(Constraints, Constraints + NumConstraints, this->Constraints); C.Deallocate(this->Clobbers); this->Clobbers = new (C) StringLiteral*[NumClobbers]; @@ -756,8 +757,9 @@ GCCAsmStmt::GCCAsmStmt(const ASTContext &C, SourceLocation asmloc, Exprs = new (C) Stmt*[NumExprs]; std::copy(exprs, exprs + NumExprs, Exprs); - Constraints = new (C) StringLiteral*[NumExprs]; - std::copy(constraints, constraints + NumExprs, Constraints); + unsigned NumConstraints = NumOutputs + NumInputs; + Constraints = new (C) StringLiteral*[NumConstraints]; + std::copy(constraints, constraints + NumConstraints, Constraints); Clobbers = new (C) StringLiteral*[NumClobbers]; std::copy(clobbers, clobbers + NumClobbers, Clobbers); -- 2.7.4