Status

()

P4
normal
RESOLVED FIXED
18 years ago
18 years ago

People

(Reporter: vda, Assigned: timeless)

Tracking

({memory-leak})

Trunk
x86
All
memory-leak
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

18 years ago
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

18 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

18 years ago
->Networking
Assignee: asa → neeti
Status: UNCONFIRMED → NEW
Component: Browser-General → Networking
Ever confirmed: true
QA Contact: doronr → benc

Comment 3

18 years ago
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

Updated

18 years ago
OS: other → All

Comment 4

18 years ago
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;
 }
Keywords: patch
Priority: -- → P4
Target Milestone: --- → mozilla0.9.3

Comment 5

18 years ago
Created attachment 41479 [details] [diff] [review]
both patches
(although putting the second opening brace on the same line would probably be
preferable)

Comment 8

18 years ago
--> timeless for checkin
Assignee: gagan → timeless
Target Milestone: mozilla0.9.3 → ---
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

Comment 10

18 years ago
fixed
Status: NEW → RESOLVED
Last Resolved: 18 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.