Bugzilla Bug 89539 Memory leak(s) when memory allocation fails.

r=dbaron sr=blizzard
This commit is contained in:
timeless%mac.com 2001-08-01 02:13:00 +00:00
parent 46dc9b0d8e
commit eaa56a62f2

View File

@ -506,10 +506,13 @@ nsProtocolProxyService::AddNoProxyFor(const char* iHost, PRInt32 iPort)
if (!hp) if (!hp)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
hp->host = new nsCString(iHost); hp->host = new nsCString(iHost);
if (!hp->host) {
delete hp;
return NS_ERROR_OUT_OF_MEMORY;
}
hp->port = iPort; hp->port = iPort;
nsAutoLock lock(mArrayLock); nsAutoLock lock(mArrayLock);
return (mFiltersArray.AppendElement(hp)) ? NS_OK : NS_ERROR_FAILURE; return (mFiltersArray.AppendElement(hp)) ? NS_OK : NS_ERROR_FAILURE;
} }
@ -592,8 +595,10 @@ nsProtocolProxyService::LoadFilters(const char* filters)
if (!hp) if (!hp)
return; // fail silently return; // fail silently
hp->host = new nsCString(np, endproxy-np); hp->host = new nsCString(np, endproxy-np);
if (!hp->host) if (!hp->host) {
delete hp;
return; return;
}
hp->port = nport>0 ? nport : -1; hp->port = nport>0 ? nport : -1;
mFiltersArray.AppendElement(hp); mFiltersArray.AppendElement(hp);