From f59e41e64406bbd9cc2eab054c3651166cdf5340 Mon Sep 17 00:00:00 2001 From: "joki%netscape.com" Date: Sat, 25 Jul 1998 01:53:54 +0000 Subject: [PATCH] Fix for unitialized var and missing add/release ref pair in the GetScriptGlobalObject call git-svn-id: svn://10.0.0.236/trunk@6476 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsWebShell.cpp | 8 ++++++++ mozilla/webshell/src/nsWebShell.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 2c4014d9994..f283da3868f 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -208,6 +208,9 @@ nsWebShell::nsWebShell() { NS_INIT_REFCNT(); mHistoryIndex = -1; + + mScriptGlobal = nsnull; + mScriptContext = nsnull; } nsWebShell::~nsWebShell() @@ -222,6 +225,9 @@ nsWebShell::~nsWebShell() NS_IF_RELEASE(mContainer); NS_IF_RELEASE(mObserver); + NS_IF_RELEASE(mScriptGlobal); + NS_IF_RELEASE(mScriptContext); + // Release references on our children ReleaseChildren(); @@ -1070,7 +1076,9 @@ nsWebShell::GetScriptGlobalObject(nsIScriptGlobalObject** aGlobal) return res; } } + *aGlobal = mScriptGlobal; + NS_ADDREF(mScriptGlobal); return res; } diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 2c4014d9994..f283da3868f 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -208,6 +208,9 @@ nsWebShell::nsWebShell() { NS_INIT_REFCNT(); mHistoryIndex = -1; + + mScriptGlobal = nsnull; + mScriptContext = nsnull; } nsWebShell::~nsWebShell() @@ -222,6 +225,9 @@ nsWebShell::~nsWebShell() NS_IF_RELEASE(mContainer); NS_IF_RELEASE(mObserver); + NS_IF_RELEASE(mScriptGlobal); + NS_IF_RELEASE(mScriptContext); + // Release references on our children ReleaseChildren(); @@ -1070,7 +1076,9 @@ nsWebShell::GetScriptGlobalObject(nsIScriptGlobalObject** aGlobal) return res; } } + *aGlobal = mScriptGlobal; + NS_ADDREF(mScriptGlobal); return res; }