Mismatched allocators in nsStandardURL and nsDiskCacheMap

REOPENED
Assigned to

Status

()

P3
normal
REOPENED
10 years ago
a year ago

People

(Reporter: neil, Assigned: neil)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [necko-backlog])

Attachments

(2 attachments)

(Assignee)

Description

10 years ago
nsStandardURL uses free to free memory that may or may not have been allocated using malloc. I made all the allocations use the XPCOM allocator as the resulting string could then be Adopt()ed by the out parameter.

nsDiskCacheMap uses PR_FREEIF to free memory that was allocated with realloc. I decided it was easier just to change the allocator in that case.
(Assignee)

Comment 1

10 years ago
Created attachment 368408 [details] [diff] [review]
Proposed patch

I also got rid of the p/*result hacks.
Assignee: nobody → neil
Status: NEW → ASSIGNED
Attachment #368408 - Flags: superreview?(cbiesinger)
Attachment #368408 - Flags: review?(cbiesinger)
Attachment #368408 - Flags: superreview?(cbiesinger)
Attachment #368408 - Flags: superreview+
Attachment #368408 - Flags: review?(cbiesinger)
Attachment #368408 - Flags: review+
(Assignee)

Comment 2

10 years ago
Pushed changeset 6be239399910 to mozilla-central.
Status: ASSIGNED → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → FIXED
(Assignee)

Comment 3

10 years ago
I found a couple more mismatches.

The first is that mHostA is sometimes allocated using nsCRT::strdup and other times using ToNewCString. Presumably the reason it isn't an nsXPIDLCString is to save memory?

The second is that nsHttpBasicAuth uses calloc(!) for an XPCOM out parameter.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
(Assignee)

Comment 4

10 years ago
Created attachment 369878 [details] [diff] [review]
nsXPIDLCString conversion

Not asking for review because you probably don't want this version.
Whiteboard: [necko-backlog]
You need to log in before you can comment on or make changes to this bug.