MLK: Memory leak of 22 bytes from 1 block allocated in PR_Malloc

VERIFIED FIXED

Status

VERIFIED FIXED
17 years ago
10 years ago

People

(Reporter: naving, Assigned: naving)

Tracking

({memory-leak})

Trunk
x86
Windows NT
memory-leak

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

17 years ago
Cancelling a news message leaks here....

        Distribution of leaked blocks
        Allocation location
        malloc         [dbgheap.c:129]
        PR_Malloc      [prmem.c:54]
        msg_extract_Header_address_mailboxes [nsMsgHeaderParser.cpp:1027]
                size += j + 2;
            }
        
     =>     result = (char*)PR_Malloc(size + 1);
            if (!result)
                        {
                            PR_Free(addrs);
                nsMsgHeaderParser::ExtractHeaderAddressMailboxes(char 
const*,char const*,char * *) [nsMsgHeaderParser.cpp:205]
                          (void) NS_ConvertUTF8toUCS2(line).get(); // asserts if 
invalid UTF-8
                    #endif
                    
                 =>     *mailboxes = msg_extract_Header_address_mailboxes(line);
                        return NS_OK;
                      }
                      else
                nsNNTPProtocol::CheckIfAuthor(nsISupports *,void *) 
[nsNNTPProtocol.cpp:4248]
                    
                        char *us = nsnull;
                        char *them = nsnull;
                 =>     nsresult rv1 = 
parser->ExtractHeaderAddressMailboxes(nsnull, cancelInfo->from, &us);
                        nsresult rv2 = 
parser->ExtractHeaderAddressMailboxes(nsnull, cancelInfo->old_from, &them);
                    
                        PR_LOG(NNTP,PR_LOG_ALWAYS,("us = %s, them = %s", us, 
them));
                nsSupportsArray::EnumerateForwards((*)(nsISupports *,void 
*),void *) [nsSupportsArray.cpp:684]
                      PRBool  running = PR_TRUE;
                    
                      while (running && (++aIndex < (PRInt32)mCount)) {
                 =>     running = (*aFunc)(mArray[aIndex], aData);
                      }
                      return running;
                    }
                nsNNTPProtocol::DoCancel(void) [nsNNTPProtocol.cpp:4361]
                              if (NS_FAILED(rv)) return -1;
                    
                              // CheckIfAuthor will set cancelInfo.from if a 
match is found
                 =>           identities->EnumerateForwards(CheckIfAuthor, (void 
*)&cancelInfo);
                          }
                    
                          if (!cancelInfo.from) {
                nsNNTPProtocol::ProcessProtocolState(nsIURI *,nsIInputStream 
*,UINT,UINT) [nsNNTPProtocol.cpp:5267]
                nsMsgProtocol::OnDataAvailable(nsIRequest *,nsISupports 
*,nsIInputStream *,UINT,UINT) [nsMsgProtocol.cpp:262]
                nsOnDataAvailableEvent::HandleEvent(void) 
[nsStreamListenerProxy.cpp:193]
(Assignee)

Updated

17 years ago
Keywords: mlk
Summary: [W] MLK: Memory leak of 22 bytes from 1 block allocated in PR_Malloc → MLK: Memory leak of 22 bytes from 1 block allocated in PR_Malloc
(Assignee)

Comment 1

17 years ago
Created attachment 62566 [details] [diff] [review]
proposed fix

free 'us' and 'them'.
(Assignee)

Comment 2

17 years ago
Created attachment 62568 [details] [diff] [review]
proposed fix

use nsXPIDLCString for 'us' and 'them'
Attachment #62566 - Attachment is obsolete: true
Comment on attachment 62568 [details] [diff] [review]
proposed fix

sr=sspitzer

does the PR_LOG() still do the right thing?
Attachment #62568 - Flags: superreview+
(Assignee)

Comment 4

17 years ago
fixed PR_LOG as well
Status: NEW → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → FIXED
Nice work, thanks for filing/fixing this.

Verified FIXED using Windows 2000, latest trunk build as of 2:30 pm 12-31-2001, 
running Purify.
Status: RESOLVED → VERIFIED
Product: MailNews → Core
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.