summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2019-02-16 13:06:43 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2019-02-16 13:06:43 +0000
commitde861bea6481f2b44f4ca908ea378b093e29924d (patch)
tree5bab683f93aa2bd8636dbf628673c967122f52db /Source
parenteb7b989c6173fd22911d69636e64f2e4a044c1d6 (diff)
downloadswig-de861bea6481f2b44f4ca908ea378b093e29924d.tar.gz
Memory leak fixes calling Swig_scopename_split
Diffstat (limited to 'Source')
-rw-r--r--Source/Swig/naming.c17
-rw-r--r--Source/Swig/symbol.c4
-rw-r--r--Source/Swig/typesys.c6
3 files changed, 13 insertions, 14 deletions
diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c
index 136df1987..1b6c963e7 100644
--- a/Source/Swig/naming.c
+++ b/Source/Swig/naming.c
@@ -439,8 +439,8 @@ DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType
rn = name_object_get(namehash, name, decl, ncdecl);
}
if (!rn && Swig_scopename_check(name)) {
- String *nprefix = NewStringEmpty();
- String *nlast = NewStringEmpty();
+ String *nprefix = 0;
+ String *nlast = 0;
Swig_scopename_split(name, &nprefix, &nlast);
rn = name_object_get(namehash, nlast, decl, ncdecl);
Delete(nlast);
@@ -579,8 +579,8 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d
if (name && SwigType_istemplate(name)) {
String *nodetype = nodeType(node);
if (nodetype && (Equal(nodetype, "constructor") || Equal(nodetype, "destructor"))) {
- String *nprefix = NewStringEmpty();
- String *nlast = NewStringEmpty();
+ String *nprefix = 0;
+ String *nlast = 0;
String *tprefix;
Swig_scopename_split(name, &nprefix, &nlast);
tprefix = SwigType_templateprefix(nlast);
@@ -1434,8 +1434,8 @@ String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname,
if (name && n && SwigType_istemplate(name)) {
String *nodetype = nodeType(n);
if (nodetype && (Equal(nodetype, "constructor") || Equal(nodetype, "destructor"))) {
- String *nprefix = NewStringEmpty();
- String *nlast = NewStringEmpty();
+ String *nprefix = 0;
+ String *nlast = 0;
String *tprefix;
Swig_scopename_split(name, &nprefix, &nlast);
tprefix = SwigType_templateprefix(nlast);
@@ -1659,12 +1659,13 @@ String *Swig_name_str(Node *n) {
if (SwigType_istemplate(name)) {
String *nodetype = nodeType(n);
if (nodetype && (Equal(nodetype, "constructor") || Equal(nodetype, "destructor"))) {
- String *nprefix = NewStringEmpty();
- String *nlast = NewStringEmpty();
+ String *nprefix = 0;
+ String *nlast = 0;
String *tprefix;
Swig_scopename_split(name, &nprefix, &nlast);
tprefix = SwigType_templateprefix(nlast);
Delete(nlast);
+ Delete(nprefix);
Delete(name);
name = tprefix;
}
diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c
index ff704b87d..aacaf24be 100644
--- a/Source/Swig/symbol.c
+++ b/Source/Swig/symbol.c
@@ -1039,8 +1039,8 @@ static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symt
return 0;
if (!prefix) {
Node *n;
- String *bname;
- String *prefix;
+ String *bname = 0;
+ String *prefix = 0;
Swig_scopename_split(name, &prefix, &bname);
n = symbol_lookup_qualified(bname, symtab, prefix, local, checkfunc);
Delete(bname);
diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c
index e3adce1e9..7564db1a6 100644
--- a/Source/Swig/typesys.c
+++ b/Source/Swig/typesys.c
@@ -839,10 +839,8 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) {
newtype = 1;
type = template_parameters_resolve(base);
}
- if (namebase)
- Delete(namebase);
- if (nameprefix)
- Delete(nameprefix);
+ Delete(namebase);
+ Delete(nameprefix);
} else {
if (SwigType_isfunction(base)) {
List *parms;