Closed
Bug 1279247
Opened 8 years ago
Closed 8 years ago
(coverity) resouce leak: mailnews/mime/emitters/nsMimeXmlEmitter.cpp : |l10nTagName| not released all the time.
Categories
(MailNews Core :: MIME, defect)
MailNews Core
MIME
Tracking
(Not tracked)
RESOLVED
FIXED
Thunderbird 50.0
People
(Reporter: ishikawa, Assigned: ishikawa)
References
(Blocks 1 open bug, )
Details
(Keywords: coverity, Whiteboard: CID 1137493)
Attachments
(1 file, 1 obsolete file)
922 bytes,
patch
|
ishikawa
:
review+
|
Details | Diff | Splinter Review |
Coverity found this: 98 UtilityWrite("<headerdisplayname>"); 4. alloc_fn: Storage is returned from allocation function LocalizeHeaderName. [show details] 5. var_assign: Assigning: l10nTagName = storage returned from this->LocalizeHeaderName(upCaseTag, tagName). 99 char *l10nTagName = LocalizeHeaderName(upCaseTag, tagName); 6. Condition !l10nTagName, taking false branch 7. Condition !*l10nTagName, taking true branch 100 if ( (!l10nTagName) || (!*l10nTagName) ) 8. Falling through to end of if statement 101 UtilityWrite(tagName); 102 else 103 { 104 UtilityWrite(l10nTagName); 105 PR_FREEIF(l10nTagName); 106 } 107 108 UtilityWrite(": "); 109 UtilityWrite("</headerdisplayname>"); 110 111 // Now write out the actual value itself and move on! 112 // 113 UtilityWrite(newValue); 114 UtilityWrite("</header>"); 115 116 NS_Free(upCaseTag); 9. Condition newValue, taking true branch 117 PR_FREEIF(newValue); 118 CID 1137493 (#1 of 1): Resource leak (RESOURCE_LEAK)10. leaked_storage: Variable l10nTagName going out of scope leaks the storage it points to. 119 return NS_OK; 120} Observation. 105 PR_FREEIF(l10nTagName); This can be simply moved out of else { } so that it is always executed before return. This is because I think PR_FREEIF() checks the nullness of its argument before callling PR_Free().
Assignee | ||
Comment 1•8 years ago
|
||
Here is a proposed patch.
Assignee | ||
Updated•8 years ago
|
Attachment #8762567 -
Attachment description: Bug 1279247 - release |l10nTagName| always.coverity-1137493.patch → Bug 1279247 - release |l10nTagName| always.
Comment 2•8 years ago
|
||
Comment on attachment 8762567 [details] [diff] [review] Bug 1279247 - release |l10nTagName| always. Review of attachment 8762567 [details] [diff] [review]: ----------------------------------------------------------------- Don't forget to ask for review, or patches will just languish in bugzilla. I'll r this one now though. ::: mailnews/mime/emitters/nsMimeXmlEmitter.cpp @@ +105,2 @@ > } > + PR_FREEIF(l10nTagName); /* call this always */ please remove the comment
Attachment #8762567 -
Flags: review+
Updated•8 years ago
|
Assignee: nobody → ishikawa
Assignee | ||
Comment 3•8 years ago
|
||
Patch fixed by removing comment. Carrying over: r=mkmelin+mozilla Thank you for noticing the missed review entry (!)
Attachment #8762567 -
Attachment is obsolete: true
Attachment #8762602 -
Flags: review+
https://hg.mozilla.org/comm-central/rev/b46028761bcef481600afd2364d2e636040a884c
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 50.0
You need to log in
before you can comment on or make changes to this bug.
Description
•