diff --git a/docshell/base/nsAboutRedirector.cpp b/docshell/base/nsAboutRedirector.cpp index 80155bc02496..26fe6b222502 100644 --- a/docshell/base/nsAboutRedirector.cpp +++ b/docshell/base/nsAboutRedirector.cpp @@ -147,7 +147,7 @@ nsAboutRedirector::NewChannel(nsIURI* aURI, tempChannel->SetOriginalURI(aURI); - NS_ADDREF(*aResult = tempChannel); + tempChannel.forget(aResult); return rv; } } @@ -186,9 +186,6 @@ nsAboutRedirector::GetIndexedDBOriginPostfix(nsIURI* aURI, nsAString& aResult) nsresult nsAboutRedirector::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult) { - nsAboutRedirector* about = new nsAboutRedirector(); - NS_ADDREF(about); - nsresult rv = about->QueryInterface(aIID, aResult); - NS_RELEASE(about); - return rv; + nsRefPtr about = new nsAboutRedirector(); + return about->QueryInterface(aIID, aResult); } diff --git a/docshell/base/nsDefaultURIFixup.cpp b/docshell/base/nsDefaultURIFixup.cpp index 97966d94c138..85278bc4ba44 100644 --- a/docshell/base/nsDefaultURIFixup.cpp +++ b/docshell/base/nsDefaultURIFixup.cpp @@ -105,9 +105,7 @@ nsDefaultURIFixup::CreateExposableURI(nsIURI* aURI, nsIURI** aReturn) uri->SetUserPass(EmptyCString()); } - // return the fixed-up URI - *aReturn = uri; - NS_ADDREF(*aReturn); + uri.forget(aReturn); return NS_OK; } diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 2e6891325705..25621c30b192 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -1139,8 +1139,7 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink) nsCOMPtr shistory; nsresult rv = GetSessionHistory(getter_AddRefs(shistory)); if (NS_SUCCEEDED(rv) && shistory) { - *aSink = shistory; - NS_ADDREF((nsISupports*)*aSink); + shistory.forget(aSink); return NS_OK; } return NS_NOINTERFACE; @@ -1158,8 +1157,7 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink) nsCOMPtr editingSession; mEditorData->GetEditingSession(getter_AddRefs(editingSession)); if (editingSession) { - *aSink = editingSession; - NS_ADDREF((nsISupports*)*aSink); + editingSession.forget(aSink); return NS_OK; } @@ -1757,8 +1755,7 @@ nsDocShell::CreateLoadInfo(nsIDocShellLoadInfo** aLoadInfo) NS_ENSURE_TRUE(loadInfo, NS_ERROR_OUT_OF_MEMORY); nsCOMPtr localRef(loadInfo); - *aLoadInfo = localRef; - NS_ADDREF(*aLoadInfo); + localRef.forget(aLoadInfo); return NS_OK; } @@ -6253,7 +6250,7 @@ nsDocShell::GetOnePermittedSandboxedNavigator(nsIDocShell** aSandboxedNavigator) NS_ENSURE_ARG_POINTER(aSandboxedNavigator); nsCOMPtr permittedNavigator = do_QueryReferent(mOnePermittedSandboxedNavigator); - NS_IF_ADDREF(*aSandboxedNavigator = permittedNavigator); + permittedNavigator.forget(aSandboxedNavigator); return NS_OK; } @@ -11966,8 +11963,7 @@ nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel, if (aNewEntry) { *aNewEntry = nullptr; if (NS_SUCCEEDED(rv)) { - *aNewEntry = entry; - NS_ADDREF(*aNewEntry); + entry.forget(aNewEntry); } } diff --git a/docshell/shistory/src/nsSHistory.cpp b/docshell/shistory/src/nsSHistory.cpp index 05959f192f7e..51e574d1c91f 100644 --- a/docshell/shistory/src/nsSHistory.cpp +++ b/docshell/shistory/src/nsSHistory.cpp @@ -540,8 +540,7 @@ nsSHistory::GetTransactionAtIndex(int32_t aIndex, nsISHTransaction ** aResult) if (NS_SUCCEEDED(rv) && ptr) { cnt++; if (cnt == aIndex) { - *aResult = ptr; - NS_ADDREF(*aResult); + ptr.forget(aResult); break; } else {