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 108142 490abcc57fec9442db09c9ebbb745fd102484cd1
parent 108141 4dfa1754f818d123305f55c3e9fee6449a0294eb
child 108143 4cda2cc454660949ec6faf5911c04f3dd09d71d9
push id23539
push userryanvm@gmail.com
push dateWed, 26 Sep 2012 22:55:55 +0000
treeherderautoland@ec079fd92224 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs790198
milestone18.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 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;