Closed Bug 392609 Opened 17 years ago Closed 17 years ago

InitUserID() leaks ID string

Categories

(Toolkit :: Crash Reporting, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bzbarsky, Assigned: ted)

References

Details

(Keywords: memory-leak)

Attachments

(1 file, 1 obsolete file)

463                       nsCAutoString id_str(id.ToString());

Leaks.  The header docs on ToString() say:

  Caller should free string.

Note that the best way to fix this depends on what happens in bug 392526.
Flags: blocking1.9?
Blocks: 387551
Flags: blocking1.9? → blocking1.9-
Ted: Could you have a look at this, should be an easy fix.
Assignee: nobody → ted.mielczarek
Attached patch PR_Free the pointer (obsolete) — Splinter Review
Simple fix.
Attachment #286006 - Flags: review?(benjamin)
Comment on attachment 286006 [details] [diff] [review]
PR_Free the pointer

You want nsAdoptingCString, I think.
Attachment #286006 - Flags: review?(benjamin) → review-
is that true?  In bug 392526 bz said:
"2)  The function uses an allocator which is not necessarily compatible with
    XPCOM strings (though in the common case it is).  As a result, Adopt() of
    this string is wrong."
well shoot, we shoulda fixed bug 331165 already :-(

You should be able to skip the nsCAutostring copy and do something like

nsDependentCString id_str(id_cstr);
Same thing, but using nsDependentCString.
Attachment #286006 - Attachment is obsolete: true
Attachment #286750 - Flags: review?(benjamin)
Attachment #286750 - Flags: review?(benjamin) → review+
Comment on attachment 286750 [details] [diff] [review]
+ nsDependentCString

Looking for approval, just a simple leak fix.
Attachment #286750 - Flags: approval1.9?
Attachment #286750 - Flags: approval1.9? → approval1.9+
Checked in.
Assignee: ted.mielczarek → nobody
Assignee: nobody → ted.mielczarek
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: