[PATCH 3/3] Plug memory leak in IcedTeaPluginUtilities::strSplit()
Martin Olsson
martin at minimum.se
Mon Jul 9 10:12:14 PDT 2012
---
plugin/icedteanp/IcedTeaPluginUtils.cc | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/plugin/icedteanp/IcedTeaPluginUtils.cc b/plugin/icedteanp/IcedTeaPluginUtils.cc
index c57277c..906dca4 100644
--- a/plugin/icedteanp/IcedTeaPluginUtils.cc
+++ b/plugin/icedteanp/IcedTeaPluginUtils.cc
@@ -297,7 +297,7 @@ IcedTeaPluginUtilities::strSplit(const char* str, const char* delim)
v->reserve(strlen(str)/2);
char* copy;
- // Tokening is done on a copy
+ // Tokenization is done on a copy
copy = (char*) malloc (sizeof(char)*strlen(str) + 1);
strcpy(copy, str);
@@ -306,13 +306,14 @@ IcedTeaPluginUtilities::strSplit(const char* str, const char* delim)
while (tok_ptr != NULL)
{
- // Allocation on heap since caller has no way to knowing how much will
- // be needed. Make sure caller cleans up!
+ // Allocation on heap since caller has no way to knowing how much will
+ // be needed. Make sure caller cleans up!
std::string* s = new std::string();
s->append(tok_ptr);
v->push_back(s);
tok_ptr = strtok (NULL, " ");
}
+ free(copy);
return v;
}
--
1.7.9.5
More information about the distro-pkg-dev
mailing list