Bug 790198 - Cleanup local JNI references in Android plugins r=snorp
authorSanttu Lakkala <inz@inz.fi>
Tue, 11 Sep 2012 05:19:00 -0400
changeset 108251 490abcc57fec9442db09c9ebbb745fd102484cd1
parent 108250 4dfa1754f818d123305f55c3e9fee6449a0294eb
child 108252 4cda2cc454660949ec6faf5911c04f3dd09d71d9
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewerssnorp
bugs790198
milestone18.0a1
Bug 790198 - Cleanup local JNI references in Android plugins r=snorp
dom/plugins/base/android/ANPSystem.cpp
dom/plugins/base/nsNPAPIPlugin.cpp
--- a/dom/plugins/base/android/ANPSystem.cpp
+++ b/dom/plugins/base/android/ANPSystem.cpp
@@ -53,16 +53,19 @@ jclass anp_system_loadJavaClass(NPP inst
   mozilla::PluginPRLibrary* lib = static_cast<mozilla::PluginPRLibrary*>(pinst->GetPlugin()->GetLibrary());
 
   nsCString libName;
   lib->GetLibraryPath(libName);
 
   jstring jclassName = env->NewStringUTF(className);
   jstring jlibName = env->NewStringUTF(libName.get());
   jobject obj = env->CallStaticObjectMethod(cls, method, jclassName, jlibName);
+  env->DeleteLocalRef(jlibName);
+  env->DeleteLocalRef(jclassName);
+  env->DeleteLocalRef(cls);
   return reinterpret_cast<jclass>(obj);
 }
 
 void anp_system_setPowerState(NPP instance, ANPPowerState powerState)
 {
   nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
 
   pinst->SetWakeLock(powerState == kScreenOn_ANPPowerState);
--- a/dom/plugins/base/nsNPAPIPlugin.cpp
+++ b/dom/plugins/base/nsNPAPIPlugin.cpp
@@ -2218,16 +2218,17 @@ NPError NP_CALLBACK
       JNIEnv* env = GetJNIForThread();
       if (!env)
         return NPERR_GENERIC_ERROR;
 
       jclass cls     = env->FindClass("org/mozilla/gecko/GeckoApp");
       jfieldID field = env->GetStaticFieldID(cls, "mAppContext",
                                              "Lorg/mozilla/gecko/GeckoApp;");
       jobject ret = env->GetStaticObjectField(cls, field);
+      env->DeleteLocalRef(cls);
       int32_t* i  = reinterpret_cast<int32_t*>(result);
       *i = reinterpret_cast<int32_t>(ret);
       return NPERR_NO_ERROR;
     }
 
     case kAudioTrackInterfaceV1_ANPGetValue: {
       LOG("get audio interface v1");
       ANPAudioTrackInterfaceV1 *i = (ANPAudioTrackInterfaceV1 *) result;