From 73094f0bbdb90ca2b793a1714877aaf2ee5d52c6 Mon Sep 17 00:00:00 2001 From: "waterson%netscape.com" Date: Wed, 1 Dec 1999 07:04:00 +0000 Subject: [PATCH] Fix code-path leak by using nsCOMPtr. --- chrome/src/nsChromeProtocolHandler.cpp | 16 +++++----------- rdf/chrome/src/nsChromeProtocolHandler.cpp | 16 +++++----------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/chrome/src/nsChromeProtocolHandler.cpp b/chrome/src/nsChromeProtocolHandler.cpp index 3eb6d9e0927..b0727b5270b 100644 --- a/chrome/src/nsChromeProtocolHandler.cpp +++ b/chrome/src/nsChromeProtocolHandler.cpp @@ -135,22 +135,17 @@ nsChromeProtocolHandler::NewChannel(const char* verb, nsIURI* uri, NS_WITH_SERVICE(nsIChromeRegistry, reg, kChromeRegistryCID, &rv); if (NS_FAILED(rv)) return rv; - nsIURI* chromeURI; - rv = uri->Clone(&chromeURI); // don't mangle the original + nsCOMPtr chromeURI; + rv = uri->Clone(getter_AddRefs(chromeURI)); // don't mangle the original if (NS_FAILED(rv)) return rv; rv = reg->ConvertChromeURL(chromeURI); - if (NS_FAILED(rv)) { - NS_RELEASE(chromeURI); - return rv; - } + if (NS_FAILED(rv)) return rv; + // now fetch the converted URI NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv); - if (NS_FAILED(rv)) { - NS_RELEASE(chromeURI); - return rv; - } + if (NS_FAILED(rv)) return rv; rv = serv->NewChannelFromURI(verb, chromeURI, aLoadGroup, @@ -175,7 +170,6 @@ nsChromeProtocolHandler::NewChannel(const char* verb, nsIURI* uri, (*result)->SetOwner(owner); } - NS_RELEASE(chromeURI); return rv; } diff --git a/rdf/chrome/src/nsChromeProtocolHandler.cpp b/rdf/chrome/src/nsChromeProtocolHandler.cpp index 3eb6d9e0927..b0727b5270b 100644 --- a/rdf/chrome/src/nsChromeProtocolHandler.cpp +++ b/rdf/chrome/src/nsChromeProtocolHandler.cpp @@ -135,22 +135,17 @@ nsChromeProtocolHandler::NewChannel(const char* verb, nsIURI* uri, NS_WITH_SERVICE(nsIChromeRegistry, reg, kChromeRegistryCID, &rv); if (NS_FAILED(rv)) return rv; - nsIURI* chromeURI; - rv = uri->Clone(&chromeURI); // don't mangle the original + nsCOMPtr chromeURI; + rv = uri->Clone(getter_AddRefs(chromeURI)); // don't mangle the original if (NS_FAILED(rv)) return rv; rv = reg->ConvertChromeURL(chromeURI); - if (NS_FAILED(rv)) { - NS_RELEASE(chromeURI); - return rv; - } + if (NS_FAILED(rv)) return rv; + // now fetch the converted URI NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv); - if (NS_FAILED(rv)) { - NS_RELEASE(chromeURI); - return rv; - } + if (NS_FAILED(rv)) return rv; rv = serv->NewChannelFromURI(verb, chromeURI, aLoadGroup, @@ -175,7 +170,6 @@ nsChromeProtocolHandler::NewChannel(const char* verb, nsIURI* uri, (*result)->SetOwner(owner); } - NS_RELEASE(chromeURI); return rv; }