From 57f315826ef3d4da606b4e78a4dbde76ec314f43 Mon Sep 17 00:00:00 2001 From: "peterlubczynski%netscape.com" Date: Fri, 20 Sep 2002 00:17:28 +0000 Subject: [PATCH] Fixing bug 169753: NPN_GetURL and friends fail if called before NPP_New returns r=av sr=heikki git-svn-id: svn://10.0.0.236/trunk@130092 18797224-902f-48f8-a5cc-f745e15eee43 --- .../plugin/base/src/ns4xPluginInstance.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp b/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp index 217aca5fc85..005c12c48ae 100644 --- a/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp +++ b/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp @@ -800,6 +800,13 @@ nsresult ns4xPluginInstance::InitializePlugin(nsIPluginInstancePeer* peer) } #endif + // Assign mPeer now and mark this instance as started before calling NPP_New + // because the plugin may call other NPAPI functions, like NPN_GetURLNotify, + // that assume these are set before returning. If the plugin returns failure, + // we'll clear them out below. + mPeer = peer; + mStarted = PR_TRUE; + NS_TRY_SAFE_CALL_RETURN(error, CallNPP_NewProc(fCallbacks->newp, (char *)mimetype, &fNPP, @@ -813,13 +820,13 @@ nsresult ns4xPluginInstance::InitializePlugin(nsIPluginInstancePeer* peer) ("NPP New called: this=%p, npp=%p, mime=%s, mode=%d, argc=%d, return=%d\n", this, &fNPP, mimetype, mode, count, error)); - if(error != NPERR_NO_ERROR) + if(error != NPERR_NO_ERROR) { + // since the plugin returned failure, these should not be set + mPeer = nsnull; + mStarted = PR_FALSE; + return NS_ERROR_FAILURE; - - // assign mPeer only if there was no error - mPeer = peer; - - mStarted = PR_TRUE; + } return NS_OK; }