From ba2ab1b61589501c54be5e41883a7b6210b43759 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@362062 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/Stmt.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp index e9a2c58f1a..0a4d403106 100644 --- a/lib/AST/Stmt.cpp +++ b/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.40.0