Closed
Bug 342750
Opened 18 years ago
Closed 18 years ago
NativeUConvService::GetNativeConverter leaks on failure
Categories
(Core :: Internationalization, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: timeless, Assigned: sciguyryan)
References
()
Details
(Keywords: memory-leak)
Attachments
(1 file, 2 obsolete files)
962 bytes,
patch
|
benjamin
:
review+
dbaron
:
superreview+
|
Details | Diff | Splinter Review |
this actually happens :)
Comment 2•18 years ago
|
||
Attachment #227259 -
Flags: review?
Updated•18 years ago
|
Attachment #227259 -
Flags: superreview?(benjamin)
Comment 3•18 years ago
|
||
Comment on attachment 227259 [details] [diff] [review]
patch v.1
Calling Init() without having called AddRef() is bad in general... it can easily lead to early-deleted objects. And while you're here, the multiple casts are silly.
Attachment #227259 -
Flags: superreview?(benjamin)
Attachment #227259 -
Flags: superreview-
Attachment #227259 -
Flags: review?
Assignee | ||
Comment 4•18 years ago
|
||
Patch v2
* Use |NS_ADDREF| immediately after we know |ucl| was successfully allocated a pointer (and only a single direct cast too a nsISupports pointer type).
* Check if |aResult->Init| failed, reset |aResult| back to |nsnull| and delete the |ucl| object.
Assignee: dougt → bugs
Attachment #227259 -
Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #250977 -
Flags: superreview?(benjamin)
Attachment #250977 -
Flags: review?(benjamin)
Comment 5•18 years ago
|
||
Comment on attachment 250977 [details] [diff] [review]
Patch v2
>Index: intl/uconv/native/nsNativeUConvService.cpp
>===================================================================
>RCS file: /cvsroot/mozilla/intl/uconv/native/nsNativeUConvService.cpp,v
>retrieving revision 1.5
>diff -u -4 -p -r1.5 nsNativeUConvService.cpp
>--- intl/uconv/native/nsNativeUConvService.cpp 6 Jan 2005 19:08:15 -0000 1.5
>+++ intl/uconv/native/nsNativeUConvService.cpp 9 Jan 2007 20:56:24 -0000
>@@ -375,12 +375,14 @@ NativeUConvService::GetNativeConverter(c
> IConvAdaptor* ucl = new IConvAdaptor();
> if (!ucl)
> return NS_ERROR_OUT_OF_MEMORY;
The simple way to do this is to change ucl to a
nsRefPtr<IConvAdaptor>
Then you get the addref/release pair for free.
>
>- nsresult rv = ucl->Init(from, to);
>+ NS_ADDREF(*aResult = (nsISupports*)ucl);
You should not need any cast here.
Attachment #250977 -
Flags: superreview?(benjamin)
Attachment #250977 -
Flags: review?(benjamin)
Attachment #250977 -
Flags: review-
Assignee | ||
Comment 6•18 years ago
|
||
Patch v3
Updated to Benjamin's comments.
Attachment #250977 -
Attachment is obsolete: true
Attachment #251116 -
Flags: superreview?(benjamin)
Attachment #251116 -
Flags: review?(benjamin)
Comment 7•18 years ago
|
||
Comment on attachment 251116 [details] [diff] [review]
Patch v3
IANASR
Attachment #251116 -
Flags: superreview?(dbaron)
Attachment #251116 -
Flags: superreview?(benjamin)
Attachment #251116 -
Flags: review?(benjamin)
Attachment #251116 -
Flags: review+
Comment on attachment 251116 [details] [diff] [review]
Patch v3
YSBASR
Attachment #251116 -
Flags: superreview?(dbaron) → superreview+
Assignee | ||
Updated•18 years ago
|
Whiteboard: [checkin needed]
Comment 9•18 years ago
|
||
mozilla/intl/uconv/native/nsNativeUConvService.cpp 1.6
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Whiteboard: [checkin needed]
You need to log in
before you can comment on or make changes to this bug.
Description
•