diff --git a/js/src/xpconnect/src/xpcjsruntime.cpp b/js/src/xpconnect/src/xpcjsruntime.cpp index 19e821874ccb..bce26bc52f6b 100644 --- a/js/src/xpconnect/src/xpcjsruntime.cpp +++ b/js/src/xpconnect/src/xpcjsruntime.cpp @@ -454,15 +454,19 @@ void XPCJSRuntime::UnsetContextGlobals() if(nsXPConnect::GetXPConnect()->GetRequestDepth(acx) == 0) { JS_ClearNewbornRoots(acx); - JSDHashEntryHdr* entry = - JS_DHashTableOperate(&mClearedGlobalObjects, acx, JS_DHASH_ADD); - ClearedGlobalObject* clearedGlobal = - reinterpret_cast(entry); - if(clearedGlobal) + if(acx->globalObject) { - clearedGlobal->mContext = acx; - clearedGlobal->mGlobalObject = acx->globalObject; - acx->globalObject = nsnull; + JSDHashEntryHdr* entry = + JS_DHashTableOperate(&mClearedGlobalObjects, acx, + JS_DHASH_ADD); + ClearedGlobalObject* clearedGlobal = + reinterpret_cast(entry); + if(clearedGlobal) + { + clearedGlobal->mContext = acx; + clearedGlobal->mGlobalObject = acx->globalObject; + acx->globalObject = nsnull; + } } } }