From e87b5a5ac2e1c54a14b2f0decc6199d90345bc81 Mon Sep 17 00:00:00 2001 From: "timeless%mozdev.org" Date: Thu, 19 Aug 2004 00:48:19 +0000 Subject: [PATCH] Bug 255710 nsDocShell::GetDocShellEnumerator leaks docShellEnum in failure cases patch by cst@andrew.cmu.edu r=timeless sr=jst git-svn-id: svn://10.0.0.236/trunk@160962 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsDocShell.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 3a9d6420cfc..226e5153b69 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -81,6 +81,7 @@ #include "nsICategoryManager.h" #include "nsXPCOMCID.h" #include "nsISeekableStream.h" +#include "nsAutoPtr.h" // we want to explore making the document own the load group // so we can associate the document URI with the load group. @@ -1534,7 +1535,7 @@ nsDocShell::GetDocShellEnumerator(PRInt32 aItemType, PRInt32 aDirection, nsISimp NS_ENSURE_ARG_POINTER(outEnum); *outEnum = nsnull; - nsDocShellEnumerator* docShellEnum; + nsRefPtr docShellEnum; if (aDirection == ENUMERATE_FORWARDS) docShellEnum = new nsDocShellForwardsEnumerator; else @@ -1551,9 +1552,8 @@ nsDocShell::GetDocShellEnumerator(PRInt32 aItemType, PRInt32 aDirection, nsISimp rv = docShellEnum->First(); if (NS_FAILED(rv)) return rv; - NS_ADDREF(docShellEnum); // ensure we don't lose the last ref inside the QueryInterface rv = docShellEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)outEnum); - NS_RELEASE(docShellEnum); + return rv; }