diff options
author | Adam Domurad <[email protected]> | 2013-07-30 13:49:13 -0400 |
---|---|---|
committer | Adam Domurad <[email protected]> | 2013-07-30 13:49:13 -0400 |
commit | 3a5331da7c7fa15f7c59bd38539a635206e75368 (patch) | |
tree | ee54fbf5d2407dba39d3cec57fde465e9a7ba120 /plugin/icedteanp/IcedTeaPluginUtils.cc | |
parent | c821809a6876465a504abcaa2ac1e6a448a4ea3f (diff) |
Fix many memory leaks due to utf8fromidentifier misuse
Diffstat (limited to 'plugin/icedteanp/IcedTeaPluginUtils.cc')
-rw-r--r-- | plugin/icedteanp/IcedTeaPluginUtils.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/plugin/icedteanp/IcedTeaPluginUtils.cc b/plugin/icedteanp/IcedTeaPluginUtils.cc index 204e258..d8ae1ee 100644 --- a/plugin/icedteanp/IcedTeaPluginUtils.cc +++ b/plugin/icedteanp/IcedTeaPluginUtils.cc @@ -1087,6 +1087,18 @@ void IcedTeaPluginUtilities::trim(std::string& str) { str = str.substr(start, end - start + 1); } +std::string IcedTeaPluginUtilities::NPIdentifierAsString(NPIdentifier id) { + NPUTF8* cstr = browser_functions.utf8fromidentifier(id); + if (cstr == NULL) { + /* Treat not-existing strings as empty. To tell if it was a valid string, + * use browser_functions.identifierisstring. */ + return std::string(); + } + std::string str = cstr; + browser_functions.memfree(cstr); + return str; +} + bool IcedTeaPluginUtilities::file_exists(std::string filename) { std::ifstream infile(filename.c_str()); |