Apparent memory leak in COOKIE_Read

VERIFIED FIXED in mozilla1.2beta

Status

()

Core
Networking: Cookies
P2
normal
VERIFIED FIXED
16 years ago
16 years ago

People

(Reporter: otaylor, Assigned: Stephen P. Morse)

Tracking

({memory-leak})

Trunk
mozilla1.2beta
memory-leak
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

16 years ago
I was using Mozilla as a test of my MemProf memory profiler and 
leak detector, and a number of 40 byte leaks were reported in:

  source/extensions/cookie/nsCookies.cpp:COOKIE_Read

(40 bytes is the size of a cookie structure). In a brief read-through
of the code, it looks like the culprit is the code:

1790     /* check for bad legacy cookies (domain not starting with a dot) */
1791     if (new_cookie->isDomain && *new_cookie->host != '.') {
1792       /* bad cookie, discard it */
1793       continue;
1794     }

I believe the cookie (and probably the string it contains) needs to be
freed before continuing, since it is just a pointer to a allocated
structure.

There is also a theoretical memory leak immediately after: in the
case where cookie_list couldn't be allocated, the first cookie needs
to be freed before returning.
Keywords: mlk
OS: Linux → All
Hardware: PC → All
(Assignee)

Updated

16 years ago
Status: NEW → ASSIGNED
Keywords: nsbeta1
Priority: -- → P2
Target Milestone: --- → mozilla1.2beta
(Assignee)

Comment 1

16 years ago
Created attachment 96884 [details] [diff] [review]
plug up the two leaks

Comment 2

16 years ago
Comment on attachment 96884 [details] [diff] [review]
plug up the two leaks

sr=jag
Attachment #96884 - Flags: superreview+

Comment 3

16 years ago
Comment on attachment 96884 [details] [diff] [review]
plug up the two leaks

r=sgehani
Attachment #96884 - Flags: review+
(Assignee)

Comment 4

16 years ago
patch checked in
Status: ASSIGNED → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → FIXED

Comment 5

16 years ago
verified - 09/05/02 tr builds
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.