summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprCXX.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-02-11 22:51:03 +0000
committerTed Kremenek <kremenek@apple.com>2010-02-11 22:51:03 +0000
commit9d6eb40ce7c28d4a0715c8699070ea2be41f40f7 (patch)
treea8262e5188df91d03a2b6632946c876dda08992e /clang/lib/AST/ExprCXX.cpp
parent81472e34b221efb9329acbc016913d778aa2caf0 (diff)
downloadbcm5719-llvm-9d6eb40ce7c28d4a0715c8699070ea2be41f40f7.tar.gz
bcm5719-llvm-9d6eb40ce7c28d4a0715c8699070ea2be41f40f7.zip
Fix leak in CXXNewExpr where the SubExprs array would get allocated directly using 'new[]' instead of the allocator associated with ASTContext.
llvm-svn: 95933
Diffstat (limited to 'clang/lib/AST/ExprCXX.cpp')
-rw-r--r--clang/lib/AST/ExprCXX.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 7c68290551d..f4b8333dd3a 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -73,7 +73,7 @@ Stmt::child_iterator CXXZeroInitValueExpr::child_end() {
}
// CXXNewExpr
-CXXNewExpr::CXXNewExpr(bool globalNew, FunctionDecl *operatorNew,
+CXXNewExpr::CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
Expr **placementArgs, unsigned numPlaceArgs,
bool parenTypeId, Expr *arraySize,
CXXConstructorDecl *constructor, bool initializer,
@@ -87,7 +87,7 @@ CXXNewExpr::CXXNewExpr(bool globalNew, FunctionDecl *operatorNew,
OperatorDelete(operatorDelete), Constructor(constructor),
StartLoc(startLoc), EndLoc(endLoc) {
unsigned TotalSize = Array + NumPlacementArgs + NumConstructorArgs;
- SubExprs = new Stmt*[TotalSize];
+ SubExprs = new (C) Stmt*[TotalSize];
unsigned i = 0;
if (Array)
SubExprs[i++] = arraySize;
@@ -98,6 +98,14 @@ CXXNewExpr::CXXNewExpr(bool globalNew, FunctionDecl *operatorNew,
assert(i == TotalSize);
}
+void CXXNewExpr::DoDestroy(ASTContext &C) {
+ DestroyChildren(C);
+ if (SubExprs)
+ C.Deallocate(SubExprs);
+ this->~CXXNewExpr();
+ C.Deallocate((void*)this);
+}
+
Stmt::child_iterator CXXNewExpr::child_begin() { return &SubExprs[0]; }
Stmt::child_iterator CXXNewExpr::child_end() {
return &SubExprs[0] + Array + getNumPlacementArgs() + getNumConstructorArgs();
OpenPOWER on IntegriCloud