From: Nuno Lopes Date: Sat, 10 May 2008 10:31:54 +0000 (+0000) Subject: fix free/delete mismatch problem in add/mergeProperties (found by valgrind) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6b3502c5c3eba1d3da40c4c78b31f4d8cffec051;p=clang fix free/delete mismatch problem in add/mergeProperties (found by valgrind) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50945 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index cda73d2ff9..701ad353a3 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -260,14 +260,12 @@ void ObjCInterfaceDecl::mergeProperties(ObjCPropertyDecl **Properties, // Add new properties to this buffer. memcpy(buf+NumPropertyDecl, Properties, NumNewProperties*sizeof(ObjCPropertyDecl*)); - free(PropertyDecl); + delete[] PropertyDecl; PropertyDecl = newPropertyDecl; NumPropertyDecl += NumNewProperties; } else { - PropertyDecl = new ObjCPropertyDecl*[NumNewProperties]; - memcpy(PropertyDecl, Properties, NumNewProperties*sizeof(ObjCPropertyDecl*)); - NumPropertyDecl = NumNewProperties; + addProperties(Properties, NumNewProperties); } }