Closed
Bug 201367
Opened 22 years ago
Closed 22 years ago
Delete array as if a pointer (memory leak)
Categories
(MailNews Core :: Attachments, defect)
MailNews Core
Attachments
Tracking
(Not tracked)
VERIFIED
FIXED
People
(Reporter: mstankus, Assigned: bzbarsky)
References
()
Details
(Keywords: memory-leak)
Attachments
(1 file)
|
1.11 KB,
patch
|
bbaetz
:
review+
sspitzer
:
superreview+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02
A "classic" or "traditional" memory leak found. Are there more like this?
Reproducible: Always
Steps to Reproduce:
1.Look at the code specified below!
mozilla/mailnews/base/src/nsMessenger.cpp has the following code.
Part of the code acts as though the pointers correspond to arrays (of
pointers), but the delete commands delete the elements not pointed too
rather than the array.
nsnsSaveAllAttachmentsState::~nsSaveAllAttachmentsState()
{
PRUint32 i;
for (i = 0; i < m_count; i++)
{
nsCRT::free(m_contentTypeArray[i]);
nsCRT::free(m_urlArray[i]);
nsCRT::free(m_displayNameArray[i]);
nsCRT::free(m_messageUriArray[i]);
}
delete m_contentTypeArray;
delete m_urlArray;
delete m_displayNameArray;
delete m_messageUriArray;
nsCRT::free(m_directoryName);
}
A "classic" memory leak.
| Assignee | ||
Comment 1•22 years ago
|
||
Not a browser bug.. But yes, chances are there are more like this. ;)
Assignee: asa → mscott
Severity: normal → critical
Status: UNCONFIRMED → NEW
Component: Browser-General → Attachments
Ever confirmed: true
Keywords: mlk
Product: Browser → MailNews
QA Contact: asa → stephend
Comment 2•22 years ago
|
||
maybe nsAutoArrayPtr should be used here
Comment 3•22 years ago
|
||
I do not see a real leak here. The deletes should be written as "delete[]", but
since the arrays are arrays of char ptrs, there are no destructors to run for
the array elements, it is not going to make any real difference. At least for
most compilers, anyhow.
| Assignee | ||
Comment 4•22 years ago
|
||
ccing someone who knows enough c++ to tell whether this is a leak... and
hopefully reads bugmail.
Comment 5•22 years ago
|
||
it needs to be delete[] so that more than the first element is deleted (well,
depending on the ABI and all that. ISTR that its unspecified what |delete| does
to something allocated via |new[]|)
| Assignee | ||
Comment 6•22 years ago
|
||
| Assignee | ||
Updated•22 years ago
|
Attachment #121097 -
Flags: superreview?(sspitzer)
Attachment #121097 -
Flags: review?(bbaetz)
Updated•22 years ago
|
Attachment #121097 -
Flags: review?(bbaetz) → review+
Comment 7•22 years ago
|
||
Comment on attachment 121097 [details] [diff] [review]
patch
sr=sspitzer
Attachment #121097 -
Flags: superreview?(sspitzer) → superreview+
| Assignee | ||
Comment 9•22 years ago
|
||
Checked in. Thanks for pointing out the problem, Mark!
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Verified via code-inspection using LXR:
1.265 bzbarsky%mit.edu Apr 22 10:42 Use delete[] for arrays, not delete. Bug
201367, patch by mstankus@calpoly.edu
(Mark Stankus), r=bbaetz, sr=sspitzer
Status: RESOLVED → VERIFIED
Updated•21 years ago
|
Product: MailNews → Core
Updated•17 years ago
|
Product: Core → MailNews Core
You need to log in
before you can comment on or make changes to this bug.
Description
•