From ba564d4e4e82d29ea6c5f67b76b17c79254f3417 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 5 Aug 2019 01:35:52 +0200 Subject: [PATCH] Fix memory leak of getProxyName() return value This is done not so much to fix the memory leak per se (as there are gazillions of other ones remaining), but to show that the return value of getProxyName() does need to be freed, as this was unclear previously, with it being freed in one place where this function was used, but not in the other one, here. Also state this explicitly in the function comment. --- Source/Modules/c.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Modules/c.cxx b/Source/Modules/c.cxx index 6ec35d85b..021a40be4 100644 --- a/Source/Modules/c.cxx +++ b/Source/Modules/c.cxx @@ -169,8 +169,7 @@ public: * getProxyName() * * Test to see if a type corresponds to something wrapped with a proxy class. - * Return NULL if not otherwise the proxy class name, fully qualified with - * top level namespace name if the nspace feature is used. + * Return NULL if not, otherwise the proxy class name to be freed by the caller. * ----------------------------------------------------------------------------- */ String *getProxyName(SwigType *t) { @@ -205,6 +204,7 @@ public: } if (proxyname) { enumname = NewStringf("%s_%s", proxyname, symname); + Delete(proxyname); } else { // global enum or enum in a namespace String *nspace = Getattr(n, "sym:nspace");