Need to use matching memory allocation and deallocation methods

RESOLVED FIXED in M5

Status

()

Core
XPCOM
P2
normal
RESOLVED FIXED
19 years ago
18 years ago

People

(Reporter: scottputterman, Assigned: mcmullen)

Tracking

Trunk
All
Windows NT
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

19 years ago
I get a Purify Freeing Mismatched Memory error in nsFileSpec
nsprpath::~nsprpath because modifiedNSPRPath is allocated using PL_strdup but
deallocated using delete[].  There appear to be other places in the file that
does this.
(Assignee)

Updated

19 years ago
Hardware: PC → All
Target Milestone: M5
(Assignee)

Comment 1

19 years ago
Changing platform from PC to all. Setting as an M5 (plumbing) bug.
(Assignee)

Comment 2

19 years ago
Accepting

Updated

19 years ago
Priority: P3 → P2

Comment 3

19 years ago
Upgraded priority to P2.

Comment 4

19 years ago
I'll have a patch that should cover all these issues and more in nsFileSpec.h
and nsFileSpec.cpp and the associated platform specific files fairly soon and
will attach it here then.

Comment 5

19 years ago
Created attachment 58 [details] [diff] [review]
Lot's of fixes for nsFileSpec code.

Comment 6

19 years ago
Attached fixes for nsFileSpec code:
memory leak on Mac when moving file (I think, please review).
memory leak in test (figured I might as well).
Used nsCRT and added the include to nsFileSpec.h
Fixes a lot of mismatched memory freeing on Unix, Windows and Mac.
Note:  the GetLeafName() code does NOT use new[] as the comments indicate.  It
uses strdup(), so you must deallocate with nsCRT::free().  I will follow up with
users of GetLeafName() throughout the tree.

I can checkin these fixes for you if you like, but they should knock out this
bug entirely.
(Assignee)

Comment 7

19 years ago
Bruce, you are truly a prince among men! Looking at your diffs now.
(Assignee)

Updated

19 years ago
Status: ASSIGNED → RESOLVED
Last Resolved: 19 years ago
Resolution: --- → FIXED
(Assignee)

Comment 8

19 years ago
I checked in Bruce's changes, with a couple of trivial changes of my own. Marking
fixed. Bruce, have at it with Purify again...

Comment 9

18 years ago
Bulk moving to XPCOM, in preparation for removal of XP File Handling component. 
(XPFH has received two bugs in ~5 months, and is no longer in active use.)
Component: XP File Handling → XPCOM
You need to log in before you can comment on or make changes to this bug.