Bug 536437 - work around a bug in the Mozilla plugin host where NPN_GetURLNotify can return an error and also call NPP_URLNotify, r=cjones

This commit is contained in:
Benjamin Smedberg 2010-01-05 12:12:30 -05:00
parent 75601d4658
commit ba2a2920c7
2 changed files with 29 additions and 3 deletions

View File

@ -270,6 +270,10 @@ PluginInstanceParent::AnswerPStreamNotifyConstructor(PStreamNotifyParent* actor,
const bool& file,
NPError* result)
{
bool streamDestroyed = false;
static_cast<StreamNotifyParent*>(actor)->
SetDestructionFlag(&streamDestroyed);
if (!post) {
*result = mNPNIface->geturlnotify(mNPP,
NullableStringGet(url),
@ -285,8 +289,11 @@ PluginInstanceParent::AnswerPStreamNotifyConstructor(PStreamNotifyParent* actor,
file, actor);
}
if (*result != NPERR_NO_ERROR)
PStreamNotifyParent::Call__delete__(actor, NPERR_GENERIC_ERROR);
if (!streamDestroyed) {
static_cast<StreamNotifyParent*>(actor)->ClearDestructionFlag();
if (*result != NPERR_NO_ERROR)
PStreamNotifyParent::Call__delete__(actor, NPERR_GENERIC_ERROR);
}
return true;
}

View File

@ -48,7 +48,26 @@ class StreamNotifyParent : public PStreamNotifyParent
{
friend class PluginInstanceParent;
StreamNotifyParent() { }
StreamNotifyParent()
: mDestructionFlag(NULL)
{ }
~StreamNotifyParent() {
if (mDestructionFlag)
*mDestructionFlag = true;
}
public:
// If we are destroyed within the call to NPN_GetURLNotify, notify the caller
// so that we aren't destroyed again. see bug 536437.
void SetDestructionFlag(bool* flag) {
mDestructionFlag = flag;
}
void ClearDestructionFlag() {
mDestructionFlag = NULL;
}
private:
bool* mDestructionFlag;
};
} // namespace plugins