Allocator mismatches in libjar

RESOLVED FIXED

Status

()

Core
Networking: JAR
RESOLVED FIXED
9 years ago
9 years ago

People

(Reporter: neil@parkwaycc.co.uk, Assigned: neil@parkwaycc.co.uk)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 2 obsolete attachments)

(Assignee)

Description

9 years ago
* In nsWildCard/nsZipFind, the pattern is created using PL_strdup but freed (in several places) using PR_Free
* In nsJARManifestItem the string created by CalculatedDigest using ToNewCString is freed in several places using PR_FREEIF
(Assignee)

Comment 1

9 years ago
Created attachment 371215 [details] [diff] [review]
Basic patch
Assignee: nobody → neil
Status: NEW → ASSIGNED
Attachment #371215 - Flags: superreview?(dveditz)
Attachment #371215 - Flags: review?(timeless)
(Assignee)

Comment 2

9 years ago
Actually nsWildCard and nsZipFind are separate allocations.
(Assignee)

Comment 3

9 years ago
Created attachment 371217 [details] [diff] [review]
Typo fix
Attachment #371215 - Attachment is obsolete: true
Attachment #371217 - Flags: superreview?(dveditz)
Attachment #371217 - Flags: review?(timeless)
Attachment #371215 - Flags: superreview?(dveditz)
Attachment #371215 - Flags: review?(timeless)
(Assignee)

Comment 4

9 years ago
Created attachment 371219 [details] [diff] [review]
Avoid manual memory management

Switching to nsCString reduces the amount of memory management necessary.
Attachment #371219 - Flags: superreview?(dveditz)
Attachment #371219 - Flags: review?(timeless)

Updated

9 years ago
Attachment #371219 - Flags: review?(timeless) → review+
Comment on attachment 371219 [details] [diff] [review]
Avoid manual memory management

>+++ b/modules/libjar/nsZipArchive.cpp	Mon Apr 06 11:57:36 2009 +0100
>@@ -740,17 +740,18 @@ nsZipArchive::FindInit(const char * aPat
>   if (!*aFind) {
>-    PR_FREEIF(pattern);
>+    if (pattern)
>+      PL_strfree(pattern);

It should be safe to pass null to PL_strfree()

>-  PR_FREEIF(mPattern);
>+  if (mPattern)
>+    PL_strfree(mPattern);

ditto.

sr=dveditz
Attachment #371219 - Flags: superreview?(dveditz) → superreview+
Comment on attachment 371217 [details] [diff] [review]
Typo fix

This appears to be obsoleted by attachment 371219 [details] [diff] [review].
Attachment #371217 - Attachment is obsolete: true
Attachment #371217 - Flags: superreview?(dveditz)
Attachment #371217 - Flags: review?(timeless)
(Assignee)

Comment 7

9 years ago
Pushed changeset 1fd2edfa2d49 to mozilla-central.
Status: ASSIGNED → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.