bug 368811 xpinstall shutdown crash when EM dialog left open. r/sr=jst
authordveditz@cruzio.com
Thu, 11 Oct 2007 16:04:39 -0700
changeset 6851 c3dbaeeb3cec46131677bda9c756923587ab5150
parent 6850 7ac767d946a88832bd682e22f2205d99d4068c74
child 6852 2a9eb901792e67d03d7e7dba02bf7b1e47f0c8b9
push idunknown
push userunknown
push dateunknown
bugs368811
milestone1.9a9pre
bug 368811 xpinstall shutdown crash when EM dialog left open. r/sr=jst
xpinstall/src/nsXPITriggerInfo.cpp
xpinstall/src/nsXPInstallManager.cpp
--- a/xpinstall/src/nsXPITriggerInfo.cpp
+++ b/xpinstall/src/nsXPITriggerInfo.cpp
@@ -318,17 +318,17 @@ XPITriggerEvent::Run()
     return 0;
 }
 
 
 void nsXPITriggerInfo::SendStatus(const PRUnichar* URL, PRInt32 status)
 {
     nsresult rv;
 
-    if ( mCx && mGlobalWrapper && mCbval )
+    if ( mCx && mGlobalWrapper && !JSVAL_IS_NULL(mCbval) )
     {
         // create event and post it
         nsRefPtr<XPITriggerEvent> event = new XPITriggerEvent();
         if (event)
         {
             event->URL      = URL;
             event->status   = status;
             event->cx       = mCx;
--- a/xpinstall/src/nsXPInstallManager.cpp
+++ b/xpinstall/src/nsXPInstallManager.cpp
@@ -121,18 +121,17 @@ nsXPInstallManager::nsXPInstallManager()
 
     // initialize mLastUpdate to the current time
     mLastUpdate = PR_Now();
 }
 
 
 nsXPInstallManager::~nsXPInstallManager()
 {
-    if (mTriggers)
-        delete mTriggers;
+    NS_ASSERTION(!mTriggers, "Shutdown not called, triggers still alive");
 }
 
 
 NS_IMPL_THREADSAFE_ISUPPORTS11(nsXPInstallManager,
                                nsIXPIListener,
                                nsIXPIDialogService,
                                nsIXPInstallManager,
                                nsIObserver,
@@ -243,19 +242,19 @@ nsXPInstallManager::InitManager(nsIDOMWi
         NS_WARNING("XPInstallManager called with no trigger info!");
         delete aTriggers;
         NS_RELEASE_THIS();
         return NS_ERROR_INVALID_POINTER;
     }
 
     nsresult rv = NS_OK;
 
+    mNeedsShutdown = PR_TRUE;
     mTriggers = aTriggers;
     mChromeType = aChromeType;
-    mNeedsShutdown = PR_TRUE;
 
     mParentWindow = aParentWindow;
 
     // Start downloading initial chunks looking for signatures,
     mOutstandingCertLoads = mTriggers->Size();
 
     nsXPITriggerItem *item = mTriggers->Get(--mOutstandingCertLoads);
 
@@ -911,16 +910,22 @@ void nsXPInstallManager::Shutdown()
                                        NS_GET_IID(nsIObserverService),
                                        os,
                                        NS_PROXY_SYNC | NS_PROXY_ALWAYS,
                                        getter_AddRefs(pos) );
             if (NS_SUCCEEDED(rv))
                 pos->RemoveObserver(this, XPI_PROGRESS_TOPIC);
         }
 
+        if (mTriggers)
+        {
+            delete mTriggers;
+            mTriggers = nsnull;
+        }
+
         NS_RELEASE_THIS();
     }
 }
 
 NS_IMETHODIMP
 nsXPInstallManager::LoadParams(PRUint32 aCount, const PRUnichar** aPackageList, nsIDialogParamBlock** aParams)
 {
     nsresult rv;