Closed Bug 5140 Opened 25 years ago Closed 25 years ago

Need to use matching memory allocation and deallocation methods

Categories

(Core :: XPCOM, defect, P2)

All
Windows NT
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: scottputterman, Assigned: mcmullen)

Details

Attachments

(1 file)

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.
Hardware: PC → All
Target Milestone: M5
Changing platform from PC to all. Setting as an M5 (plumbing) bug.
Accepting
Priority: P3 → P2
Upgraded priority to P2.
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.
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.
Bruce, you are truly a prince among men! Looking at your diffs now.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
I checked in Bruce's changes, with a couple of trivial changes of my own. Marking
fixed. Bruce, have at it with Purify again...
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.

Attachment

General

Created:
Updated:
Size: