Closed
Bug 89539
Opened 23 years ago
Closed 23 years ago
Memory leak
Categories
(Core :: Networking, defect, P4)
Tracking
()
RESOLVED
FIXED
People
(Reporter: vda, Assigned: timeless)
Details
(Keywords: memory-leak)
Attachments
(1 file)
1.21 KB,
patch
|
Details | Diff | Splinter Review |
nsProtocolProxyService.cpp: 571 hp = new host_port(); 572 if (!hp) 573 return; // fail silently 574 hp->host = new nsCString(np, endproxy-np); 575 if (!hp->host) 576 return; 577 hp->port = nport>0 ? nport : -1; second 'if' should do 'delete hp' before return.
Reporter | ||
Comment 1•23 years ago
|
||
Visit http://hands.stanford.edu/linux/ - automatic checker for such things. Mozilla already use LXR, what about using MC described at this url?
Comment 2•23 years ago
|
||
->Networking
Assignee: asa → neeti
Status: UNCONFIRMED → NEW
Component: Browser-General → Networking
Ever confirmed: true
QA Contact: doronr → benc
nsProtocolProxyService::AddNoProxyFor(const char* iHost, PRInt32 iPort) { if (!iHost) return NS_ERROR_NULL_POINTER; host_port* hp = new host_port(); if (!hp) return NS_ERROR_OUT_OF_MEMORY; hp->host = new nsCString(iHost); hp->port = iPort; -style looks a bit off, and also doesn't check to see if hp->host failed... scc: can these things actually happen? blame says gagan.
Assignee: neeti → gagan
Keywords: mlk
even though this is a rare edge case, any leaks when we are already on low memory are bad. So here is a patch-- Index: nsProtocolProxyService.cpp =================================================================== RCS file: /cvsroot/mozilla/netwerk/base/src/nsProtocolProxyService.cpp,v retrieving revision 1.24 diff -u -r1.24 nsProtocolProxyService.cpp --- nsProtocolProxyService.cpp 2001/06/17 05:21:52 1.24 +++ nsProtocolProxyService.cpp 2001/07/06 19:58:01 @@ -486,10 +486,13 @@ if (!hp) return NS_ERROR_OUT_OF_MEMORY; hp->host = new nsCString(iHost); + if (!hp->host) { + delete hp; + return NS_ERROR_OUT_OF_MEMORY; + } hp->port = iPort; nsAutoLock lock(mArrayLock); - return (mFiltersArray.AppendElement(hp)) ? NS_OK : NS_ERROR_FAILURE; }
r=dbaron on attachment 41479 [details] [diff] [review]
(although putting the second opening brace on the same line would probably be preferable)
Comment 8•23 years ago
|
||
--> timeless for checkin
Assignee: gagan → timeless
Target Milestone: mozilla0.9.3 → ---
Comment 9•23 years ago
|
||
Is the bracing style the same as the rest of the file in the second part of the patch? It's quite jarring. Other than that sr=blizzard
You need to log in
before you can comment on or make changes to this bug.
Description
•