From ab006f5428fd6d83f9584e7e2aa3c2046554b731 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Feb 2005 22:19:16 +0000 Subject: [PATCH] Memory leak fix in some of the scripting language modules when using default arguments in constructors. The scripting language was not taking ownership of the C++ object memory when any of the constructors that use default arguments was called. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6969 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index fdd731777..31952d0ce 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1188,6 +1188,10 @@ static void default_arguments(Node *n) { if (templatetype) Setattr(new_function,"templatetype",Copy(templatetype)); if (symtypename) Setattr(new_function,"sym:typename",Copy(symtypename)); if (templateparms) Setattr(new_function,"templateparms",CopyParmList(templateparms)); + } else if (Strcmp(nodeType(function),"constructor") == 0) { + /* only copied for constructors as this is not a user defined feature - it is hard coded in the parser */ + Node *featurenew = Getattr(function,"feature:new"); + if (featurenew) Setattr(new_function,"feature:new",Copy(featurenew)); } add_symbols(new_function);