Bug 800838 - Guard against invalid NPP when unscheduling plugin timers on Android r=blassey
This commit is contained in:
@@ -2813,7 +2813,13 @@ _scheduletimer(NPP instance, uint32_t interval, NPBool repeat, PluginTimerFunc t
|
|||||||
void NP_CALLBACK
|
void NP_CALLBACK
|
||||||
_unscheduletimer(NPP instance, uint32_t timerID)
|
_unscheduletimer(NPP instance, uint32_t timerID)
|
||||||
{
|
{
|
||||||
|
#ifdef MOZ_WIDGET_ANDROID
|
||||||
|
// Sometimes Flash calls this with a dead NPP instance. Ensure the one we have
|
||||||
|
// here is valid and maps to a nsNPAPIPluginInstance.
|
||||||
|
nsNPAPIPluginInstance *inst = nsNPAPIPluginInstance::GetFromNPP(instance);
|
||||||
|
#else
|
||||||
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
||||||
|
#endif
|
||||||
if (!inst)
|
if (!inst)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -151,6 +151,8 @@ private:
|
|||||||
Mutex mLock;
|
Mutex mLock;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static std::map<NPP, nsNPAPIPluginInstance*> sPluginNPPMap;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
@@ -190,12 +192,20 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance()
|
|||||||
mNPP.ndata = this;
|
mNPP.ndata = this;
|
||||||
|
|
||||||
PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance ctor: this=%p\n",this));
|
PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance ctor: this=%p\n",this));
|
||||||
|
|
||||||
|
#ifdef MOZ_WIDGET_ANDROID
|
||||||
|
sPluginNPPMap[&mNPP] = this;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
nsNPAPIPluginInstance::~nsNPAPIPluginInstance()
|
nsNPAPIPluginInstance::~nsNPAPIPluginInstance()
|
||||||
{
|
{
|
||||||
PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance dtor: this=%p\n",this));
|
PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance dtor: this=%p\n",this));
|
||||||
|
|
||||||
|
#ifdef MOZ_WIDGET_ANDROID
|
||||||
|
sPluginNPPMap.erase(&mNPP);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (mMIMEType) {
|
if (mMIMEType) {
|
||||||
PR_Free((void *)mMIMEType);
|
PR_Free((void *)mMIMEType);
|
||||||
mMIMEType = nullptr;
|
mMIMEType = nullptr;
|
||||||
@@ -1052,6 +1062,17 @@ void nsNPAPIPluginInstance::SetInverted(bool aInverted)
|
|||||||
mInverted = aInverted;
|
mInverted = aInverted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsNPAPIPluginInstance* nsNPAPIPluginInstance::GetFromNPP(NPP npp)
|
||||||
|
{
|
||||||
|
std::map<NPP, nsNPAPIPluginInstance*>::iterator it;
|
||||||
|
|
||||||
|
it = sPluginNPPMap.find(npp);
|
||||||
|
if (it == sPluginNPPMap.end())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nsresult nsNPAPIPluginInstance::GetDrawingModel(int32_t* aModel)
|
nsresult nsNPAPIPluginInstance::GetDrawingModel(int32_t* aModel)
|
||||||
|
|||||||
@@ -207,6 +207,8 @@ public:
|
|||||||
|
|
||||||
void SetInverted(bool aInverted);
|
void SetInverted(bool aInverted);
|
||||||
bool Inverted() { return mInverted; }
|
bool Inverted() { return mInverted; }
|
||||||
|
|
||||||
|
static nsNPAPIPluginInstance* GetFromNPP(NPP npp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nsresult NewStreamListener(const char* aURL, void* notifyData,
|
nsresult NewStreamListener(const char* aURL, void* notifyData,
|
||||||
|
|||||||
Reference in New Issue
Block a user