Bug 780831 - Guard against plugin code leaking refs in the JNI local ref table. r=snorp

This commit is contained in:
Kartikaya Gupta
2012-12-13 00:32:17 -05:00
parent a79f94da5b
commit b38d78a11f
4 changed files with 26 additions and 13 deletions

View File

@@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/PluginPRLibrary.h"
#include "nsPluginSafety.h"
// Some plugins on Windows, notably Quake Live, implement NP_Initialize using
// cdecl instead of the documented stdcall. In order to work around this,
// we force the caller to use a frame pointer.
@@ -39,6 +40,8 @@ PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs,
if (!env)
return NS_ERROR_FAILURE;
mozilla::AutoLocalJNIFrame jniFrame(env);
if (mNP_Initialize) {
*error = mNP_Initialize(bFuncs, pFuncs, env);
} else {
@@ -194,6 +197,8 @@ PluginPRLibrary::NPP_New(NPMIMEType pluginType, NPP instance,
{
if (!mNPP_New)
return NS_ERROR_FAILURE;
MAIN_THREAD_JNI_REF_GUARD;
*error = mNPP_New(pluginType, instance, mode, argc, argn, argv, saved);
return NS_OK;
}
@@ -206,6 +211,7 @@ PluginPRLibrary::NPP_ClearSiteData(const char* site, uint64_t flags,
return NS_ERROR_NOT_AVAILABLE;
}
MAIN_THREAD_JNI_REF_GUARD;
NPError result = mNPP_ClearSiteData(site, flags, maxAge);
switch (result) {
@@ -229,6 +235,7 @@ PluginPRLibrary::NPP_GetSitesWithData(InfallibleTArray<nsCString>& result)
result.Clear();
MAIN_THREAD_JNI_REF_GUARD;
char** sites = mNPP_GetSitesWithData();
if (!sites) {
return NS_OK;