Bug 980625 - Fix minor leak in nptest found by LSAN. r=josh
authorJohn Schoenick <jschoenick@mozilla.com>
Thu, 06 Mar 2014 16:56:54 -0800
changeset 191427 56ff5e931815c6fd9206f9f998d735fa49b2e4dd
parent 191426 763eb7c3207568fc73a171dfca18831c9d08355b
child 191428 a617b3b8813279d5b16c21a2a1ad562a86ee9275
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjosh
bugs980625
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 980625 - Fix minor leak in nptest found by LSAN. r=josh
dom/plugins/test/testplugin/nptest.cpp
--- a/dom/plugins/test/testplugin/nptest.cpp
+++ b/dom/plugins/test/testplugin/nptest.cpp
@@ -2051,26 +2051,31 @@ scriptableInvokeDefault(NPObject* npobj,
   STRINGZ_TO_NPVARIANT(NPN_StrDup(value.str().c_str()), *result);
   return true;
 }
 
 bool
 scriptableHasProperty(NPObject* npobj, NPIdentifier name)
 {
   if (NPN_IdentifierIsString(name)) {
-    if (NPN_GetStringIdentifier(NPN_UTF8FromIdentifier(name)) != name)
+    NPUTF8 *asUTF8 = NPN_UTF8FromIdentifier(name);
+    if (NPN_GetStringIdentifier(asUTF8) != name) {
       Crash();
+    }
+    NPN_MemFree(asUTF8);
   }
   else {
-    if (NPN_GetIntIdentifier(NPN_IntFromIdentifier(name)) != name)
+    if (NPN_GetIntIdentifier(NPN_IntFromIdentifier(name)) != name) {
       Crash();
+    }
   }
   for (int i = 0; i < int(ARRAY_LENGTH(sPluginPropertyIdentifiers)); i++) {
-    if (name == sPluginPropertyIdentifiers[i])
+    if (name == sPluginPropertyIdentifiers[i]) {
       return true;
+    }
   }
   return false;
 }
 
 bool
 scriptableGetProperty(NPObject* npobj, NPIdentifier name, NPVariant* result)
 {
   for (int i = 0; i < int(ARRAY_LENGTH(sPluginPropertyIdentifiers)); i++) {