Closed Bug 110700 Opened 24 years ago Closed 24 years ago

MLK: Memory leak of 1 byte from 1 block allocated in PL_strdup

Categories

(MailNews Core :: MIME, defect)

x86
Windows NT
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: naving, Assigned: bugzilla)

Details

(Keywords: memory-leak, Whiteboard: have fix)

Attachments

(1 file, 2 obsolete files)

Distribution of leaked blocks Allocation location malloc [msvcrt.DLL] PL_strdup [strdup.c:46] nsPrefService::GetCharPref(char const*,char * *) [nsPrefService.h:57] MimeInlineTextPlain_parse_begin [mimetpla.cpp:165] MimeMessage_close_headers [mimemsg.cpp:457] MimeMessage_parse_line [mimemsg.cpp:271] convert_and_send_buffer [mimebuf.cpp:168] mime_LineBuffer [mimebuf.cpp:255] MimeObject_parse_buffer [mimeobj.cpp:255] nsStreamConverter::OnDataAvailable(nsIRequest *,nsISupports *,nsIInputStream *,UINT,UINT) [nsStreamConverter.cpp:919] nsDocumentOpenInfo::OnDataAvailable(nsIRequest *,nsISupports *,nsIInputStream *,UINT,UINT) [nsURILoader.cpp:240] nsMailboxProtocol::ReadMessageResponse(nsIInputStream *,UINT,UINT) [nsMailboxProtocol.cpp:570] nsMailboxProtocol::ProcessProtocolState(nsIURI *,nsIInputStream *,UINT,UINT) [nsMailboxProtocol.cpp:661] nsMsgProtocol::OnDataAvailable(nsIRequest *,nsISupports *,nsIInputStream *,UINT,UINT) [nsMsgProtocol.cpp:262] nsOnDataAvailableEvent::HandleEvent(void) [nsStreamListenerProxy.cpp:193] PL_HandleEvent [plevent.c:590] md_EventReceiverProc [plevent.c:1071] ScrollDC [user32.dll] ScrollDC [user32.dll] DispatchMessageA [user32.dll]
Keywords: mlk
QA Contact: esther → stephend
we are leaking mCitationColor. Apparently an empty string in that case but could be more.
Status: NEW → ASSIGNED
We need to do the same than in MimeInlineTextPlainFlowed::MimeInlineTextPlainFlowed_parse_eof. Patch coming...
I cannot generate a diff right now because of a cvs lock :-(
Whiteboard: have fix
Attached patch Proposed fix, v1 (obsolete) — Splinter Review
Comment on attachment 60394 [details] [diff] [review] Proposed fix, v1 looks ok to me.
Attachment #60394 - Flags: review+
Comment on attachment 60394 [details] [diff] [review] Proposed fix, v1 r=varada. We should file a bug and get rid of these gotos in mime though :)
instead of doing it this way, could we make mCitation color an nsXPIDLCString or a nsCString, so that when the text object gets destroyed, we'll clean up after ourselves automatically?
yes I can but that would be a revolution in Mine to use anything else than a char* :-)
revolutions need to start somewhere =).
Attachment #60394 - Attachment is obsolete: true
Attached patch Proposed fix, v2 (obsolete) — Splinter Review
I've replaced "char *mCitationColor" by "nsXPIDLCString mCitationColor"
Comment on attachment 61124 [details] [diff] [review] Proposed fix, v2 Viva la Revolucion! one question, where we used to free the mCitation color, should we be setting it to null?
no. mCitationColor is used only in this file and we set it to an empty string every time we start using it. Therefore setting it to null when done with is wasn't needed.
Comment on attachment 61124 [details] [diff] [review] Proposed fix, v2 thanks for the explanation. r=sspitzer
Attachment #61124 - Flags: review+
Comment on attachment 61124 [details] [diff] [review] Proposed fix, v2 This patch does not work!
Attachment #61124 - Attachment is obsolete: true
Attachment #60394 - Attachment is obsolete: false
The second patch does not work because mine create new mime class using MALLOC and not new. Therefore you cannot use an XPIDLString, that will cause a crash! Seth, can you SR the first patch. Thanks.
is there any string trickery would could here, to avoid the goto? like adopting the text->mCitationColor after this line: if (obj->closed_p) return 0; nsCAutoString citationColor; citationColor.Adopt(text->mCitationColor); and then when the method returns, and the adopted parent of text- >mCitationColor goes out of scope (as it would be a stack based object), it would free the buffer? cc jag / dbaron, they've got string string kung foo.
Attachment #60394 - Attachment is obsolete: true
Attached patch Proposed fix, v3Splinter Review
Comment on attachment 61167 [details] [diff] [review] Proposed fix, v3 sr=sspitzer looks good. this is a trick we could use to fix some other confusing goto in mailnews.
Attachment #61167 - Flags: superreview+
Fixed and checked in
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Verified FIXED, using my vcard test message with inline text, running on Windows 2000 under Purify with the latest trunk build as of 11:35 pm December 10th.
Status: RESOLVED → VERIFIED
Yep, this is what I would have suggested.
Product: MailNews → Core
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: