summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-01-08 20:49:27 +0000
committerTed Kremenek <kremenek@apple.com>2009-01-08 20:49:27 +0000
commit0667123ba15875b059d4c3023fb9524ae1c97c4e (patch)
tree55cc3eb7ec8723e53b8ee54334eecb4ec6853f0b /clang/lib
parentc8938e09ca078a0958eafa27b83ef1da6cb4173c (diff)
downloadbcm5719-llvm-0667123ba15875b059d4c3023fb9524ae1c97c4e.tar.gz
bcm5719-llvm-0667123ba15875b059d4c3023fb9524ae1c97c4e.zip
Fix ObjCInterfaceDecl::Destroy and ObjCProtocolDecl::Destroy to iterate and destroy all contained ObjCMethodDecls in one sweep. This fixes a use-after-free error found by valgrind.
llvm-svn: 61943
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/DeclObjC.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 2263af7d906..b7c0cf79b94 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -73,11 +73,8 @@ void ObjCInterfaceDecl::Destroy(ASTContext& C) {
for (ivar_iterator I=ivar_begin(), E=ivar_end(); I!=E; ++I)
if (*I) (*I)->Destroy(C);
- for (instmeth_iterator I=instmeth_begin(), E=instmeth_end(); I!=E; ++I)
- if (*I) (*I)->Destroy(C);
-
- for (classmeth_iterator I=classmeth_begin(), E=classmeth_end(); I!=E; ++I)
- if (*I) (*I)->Destroy(C);
+ for (method_iterator I=meth_begin(), E=meth_end(); I!=E; ++I)
+ if (*I) const_cast<ObjCMethodDecl*>((*I))->Destroy(C);
// FIXME: Because there is no clear ownership
// role between ObjCInterfaceDecls and the ObjCPropertyDecls that they
@@ -122,11 +119,8 @@ void ObjCProtocolDecl::Destroy(ASTContext& C) {
// Referenced Protocols are not owned, so don't Destroy them.
- for (instmeth_iterator I=instmeth_begin(), E=instmeth_end(); I!=E; ++I)
- if (*I) (*I)->Destroy(C);
-
- for (classmeth_iterator I=classmeth_begin(), E=classmeth_end(); I!=E; ++I)
- if (*I) (*I)->Destroy(C);
+ for (method_iterator I=meth_begin(), E=meth_end(); I!=E; ++I)
+ if (*I) const_cast<ObjCMethodDecl*>((*I))->Destroy(C);
// FIXME: Because there is no clear ownership
// role between ObjCProtocolDecls and the ObjCPropertyDecls that they
OpenPOWER on IntegriCloud