status string leaked during composition

VERIFIED FIXED in mozilla0.8

Status

MailNews Core
Composition
VERIFIED FIXED
17 years ago
10 years ago

People

(Reporter: dbaron, Assigned: Jean-Francois Ducarroz)

Tracking

({mlk})

Trunk
mozilla0.8
x86
Linux

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

17 years ago
While writing a message from a mailto: link, the Boehm GC said the a string
was leaked allocated from:

PR_Malloc
nsMemoryImpl::Alloc(unsigned int)
nsMemory::Alloc(unsigned int)
nsCppSharedAllocator::allocate(unsigned int, void const *)
nsCRT::strndup(unsigned wchar_t const *, unsigned int)
nsCRT::strdup(unsigned wchar_t const *)
nsMsgComposeAndSend::SetStatusMessage(unsigned wchar_t const *)
nsMsgComposeAndSend::Init(nsIMsgIdentity *, nsMsgCompFields *, nsFileSpec *,
int, int, int, nsIMessage *, char const *, char const *, unsigned int,
nsMsgAttachmentData const *, nsMsgAttachedFile const *)
nsMsgComposeAndSend::CreateAndSendMessage(nsIEditorShell *, nsIMsgIdentity *,
nsIMsgCompFields *, int, int, int, nsIMessage *, char const *, char const *,
unsigned int, nsMsgAttachmentData const *, nsMsgAttachedFile const *, void *,
nsIMsgSendListener **, unsigned int)
nsMsgCompose::_SendMsg(int, nsIMsgIdentity *, int)
nsMsgCompose::SendMsg(int, nsIMsgIdentity *)
XPTC_InvokeByIndex

It looks like the problem is that nsMsgComposeAndSend::SetStatusMessage does an
unnecessary strdup and never frees the result.  AFAICT, that stdrup should just
be removed and you should use aMsgString directly.

Also, while I'm here, I'll point out that nsMsgStatusFeedback::ShowStatusString
is also inefficient:  the nsAutoString is unnecessary and could be removed (it's
never used).
(Reporter)

Updated

17 years ago
Keywords: mlk

Comment 1

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

Comment 2

17 years ago
The above patch fixes the leak in nsMsgComposeAndSend::SetStatusMessage and
removes the unused nsAutoString in nsMsgStatusFeedback::ShowStatusString (as per
dbaron's comments).  Can someone look at this for an r/sr=?
(Reporter)

Updated

17 years ago
Keywords: patch, review
(Assignee)

Comment 3

17 years ago
Right thing to do. R=ducarroz. Please send an email to reviewers@mozilla.org and
mscott@netscape.com for a super review. Good job. Once you get the SR, I'll
check in the patch for you.
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.8

Comment 4

17 years ago
sr=mscott. thanks for the code contribution!
(Assignee)

Comment 5

17 years ago
Fixed and checked in. Thanks Kevin Higgins.
Status: ASSIGNED → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → FIXED

Comment 6

17 years ago
David, can you please verify this.  Thanks!
QA Contact: esther → stephend
verified fixed.
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.