Closed Bug 162129 Opened 22 years ago Closed 22 years ago

Apparent memory leak in COOKIE_Read

Categories

(Core :: Networking: Cookies, defect, P2)

defect

Tracking

()

VERIFIED FIXED
mozilla1.2beta

People

(Reporter: otaylor, Assigned: morse)

Details

(Keywords: memory-leak)

Attachments

(1 file)

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
Status: NEW → ASSIGNED
Keywords: nsbeta1
Priority: -- → P2
Target Milestone: --- → mozilla1.2beta
Comment on attachment 96884 [details] [diff] [review]
plug up the two leaks

sr=jag
Attachment #96884 - Flags: superreview+
Comment on attachment 96884 [details] [diff] [review]
plug up the two leaks

r=sgehani
Attachment #96884 - Flags: review+
patch checked in
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
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.

Attachment

General

Created:
Updated:
Size: