Closed Bug 1280056 Opened 8 years ago Closed 4 years ago

(coverity) resource leak: mailnews/mime/emitters/nsMimeBaseEmitter.cpp: |l10nTagName| is not freed always.

Categories

(MailNews Core :: MIME, defect)

defect
Not set
normal

Tracking

(thunderbird_esr78 wontfix, thunderbird82 wontfix)

RESOLVED FIXED
83 Branch
Tracking Status
thunderbird_esr78 --- wontfix
thunderbird82 --- wontfix

People

(Reporter: ishikawa, Assigned: mkmelin)

References

(Blocks 1 open bug, )

Details

(Keywords: coverity, Whiteboard: CID 450614)

Attachments

(1 file)

Coverity found this:
|l10nTagName| is not freed in an early error return path.

 846
    14. alloc_fn: Storage is returned from allocation function LocalizeHeaderName. [show details]
    15. var_assign: Assigning: l10nTagName = storage returned from this->LocalizeHeaderName(newTagName.get(), field).
 847  char *l10nTagName = LocalizeHeaderName(newTagName.get(), field);
    16. Condition !l10nTagName, taking false branch
    17. Condition !*l10nTagName, taking true branch
 848  if ( (!l10nTagName) || (!*l10nTagName) )
    18. Falling through to end of if statement
 849    mHTMLHeaders.Append(field);
 850  else
 851  {
 852    mHTMLHeaders.Append(l10nTagName);
 853    PR_FREEIF(l10nTagName);
 854  }
 855
 856  mHTMLHeaders.Append(": ");
    19. Condition this->mFormat == nsMimeOutput::nsMimeMessageSaveAs, taking false branch
 857  if (mFormat == nsMimeOutput::nsMimeMessageSaveAs)
 858    mHTMLHeaders.Append("</b>");
 859  else
 860    mHTMLHeaders.Append("</div>");
 861
 862  // Now write out the actual value itself and move on!
 863  //
 864  mHTMLHeaders.Append(newValue);
 865  mHTMLHeaders.Append("</td>");
 866
 867  mHTMLHeaders.Append("</tr>");
 868
    20. Condition newValue, taking true branch
 869  PR_FREEIF(newValue);
    CID 450614 (#1 of 1): Resource leak (RESOURCE_LEAK)21. leaked_storage: Variable l10nTagName going out of scope leaks the storage it points to.
 870  return NS_OK;
 871}

Observation:

853    PR_FREEIF(l10nTagName);

this should be moved out of else { } so that it is always executed.

I suppose the leak is always 0, but we might as well clear this one up.

Assignee: nobody → mkmelin+mozilla
Status: NEW → ASSIGNED
Attachment #9180870 - Flags: review?(benc)
Attachment #9180870 - Flags: review?(benc) → review+

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/18910a0a17dd
coverity: mailnews/mime/emitters/nsMimeBaseEmitter.cpp: |l10nTagName| is not freed always. r=benc

Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED

Doesn't seem worth uplifting.

Target Milestone: --- → 83 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: