Closed Bug 155032 Opened 22 years ago Closed 22 years ago

Memory leak of 18 bytes from 1 block allocated in nsSOCKSSocketInfo::GetProxyHost

Categories

(Core :: Networking, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla1.1beta

People

(Reporter: stephend, Assigned: bbaetz)

Details

(Keywords: memory-leak)

Attachments

(1 file)

I hope this isn't bogus, but I see this on Windows 2000 running under Purify, 
just accessing my IMAP account with a SOCKS Proxy V5 server.

If this turns out to be bogus, I'll invalidate it faster than you can 
exclaim 'Shazam'.

    [W] MLK: Memory leak of 18 bytes from 1 block allocated in PL_strdup
    Distribution of leaked blocks
    Allocation location
        malloc         [MSVCRT.DLL]
        PL_strdup      [strdup.c:46]
        nsSOCKSSocketInfo::GetProxyHost(char * *) [nsSOCKSIOLayer.cpp:103]
                if (!aProxyHost) return NS_ERROR_NULL_POINTER;
                if (mProxyHost)
                {
         =>         *aProxyHost = nsCRT::strdup(mProxyHost);
                    return (*aProxyHost == nsnull) ? NS_ERROR_OUT_OF_MEMORY : 
NS_OK;
                }
                else
        ???            [ip=0x0922b288]
        nsSOCKSIOLayerConnect [nsSOCKSIOLayer.cpp:568]
                PRHostEnt hostentry;
                char * proxyHost;
            
         =>     nsresult rv = info->GetProxyHost(&proxyHost);
            
                if (NS_FAILED(rv) || !proxyHost || !(*proxyHost)) {
                    return PR_FAILURE;
        PR_Connect     [priometh.c:181]
        nsSocketTransport::doConnection(short) [nsSocketTransport.cpp:955]
                    //    This is only done the first time doConnection(...) is 
called.
                    //
                    if (NS_SUCCEEDED(rv)) {
         =>             status = PR_Connect(mSocketFD, mNetAddress, 
gConnectTimeout);
                        if (PR_SUCCESS != status) {
                            PRErrorCode code = PR_GetError();
                            //
        nsSocketTransport::Process(short) [nsSocketTransport.cpp:538]
        nsSocketTransportService::ProcessWorkQ(void) 
[nsSocketTransportService.cpp:317]
        nsSocketTransportService::Run(void) [nsSocketTransportService.cpp:563]
        nsThread::Main(void *) [nsThread.cpp:120]
        PR_NativeRunThread [pruthr.c:433]
        TlsSetValue    [KERNEL32.dll]
Keywords: mlk
QA Contact: benc → stephend
This looks real.

If you change like 566-570 in nsSOCKSIOLayer.cpp (the proxyHost delcaration) to:

nsXPIDLCString proxyHost;
nsresult rv = info->GetProxyHost(getter_Copies(proxyHost));
if (NS_FAILED(rv) || proxyHost.IsEmpty()) {

then add .get() to fix the compile errors, does that fix the leak?
Add get() where?

Can you just provide a patch that I can test, please?  Thanks.
Attached patch patchSplinter Review
This compiles, but I haven't tested it runs.
This both works and seems to fix the leak on Windows 2000.

SOCKS operations remain normal with this patch.
Comment on attachment 89706 [details] [diff] [review]
patch

r=smeredith
Attachment #89706 - Flags: review+
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.1beta
Comment on attachment 89706 [details] [diff] [review]
patch

sr=alecf
Attachment #89706 - Flags: superreview+
Checked into trunk.
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Verified FIXED, thanks for taking care of this so rapidly.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: