Closed Bug 342750 Opened 18 years ago Closed 18 years ago

NativeUConvService::GetNativeConverter leaks on failure

Categories

(Core :: Internationalization, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: timeless, Assigned: sciguyryan)

References

()

Details

(Keywords: memory-leak)

Attachments

(1 file, 2 obsolete files)

this actually happens :)
Reassigning per blame
Assignee: smontagu → dougt
Attached patch patch v.1 (obsolete) — Splinter Review
Attachment #227259 - Flags: review?
Attachment #227259 - Flags: superreview?(benjamin)
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?
Attached patch Patch v2 (obsolete) — Splinter Review
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 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-
Attached patch Patch v3Splinter Review
Patch v3 Updated to Benjamin's comments.
Attachment #250977 - Attachment is obsolete: true
Attachment #251116 - Flags: superreview?(benjamin)
Attachment #251116 - Flags: review?(benjamin)
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+
Whiteboard: [checkin needed]
mozilla/intl/uconv/native/nsNativeUConvService.cpp 1.6
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Whiteboard: [checkin needed]
Depends on: 376141
Blocks: 372648
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: