Open Bug 1279931 Opened 4 years ago

(coverity) resource leak: mailnews/mime/src/mimemoz2.cpp: |urlSpec| is not released on an early return.

Categories

(MailNews Core :: MIME, defect)

defect
Not set

Tracking

(Not tracked)

People

(Reporter: ishikawa, Unassigned)

References

(Blocks 1 open bug, )

Details

(Keywords: coverity, Whiteboard: CID 1137478)

Coverity found this:


306    }
307    else
308    {
309      // if the mime object contains an external attachment URL, then use it, otherwise
310      // fall back to creating an attachment url based on the message URI and the
311      // part number.
312      urlSpec = mime_external_attachment_url(object);
   7. Condition urlSpec, taking false branch
313      isExternalAttachment = urlSpec ? true : false;
   8. Condition !urlSpec, taking true branch
314      if (!urlSpec)
   9. alloc_fn: Storage is returned from allocation function mime_set_url_part. [show details]
   10. var_assign: Assigning: urlSpec = storage returned from mime_set_url_part(aMessageURL, part.get(), true).
315        urlSpec = mime_set_url_part(aMessageURL, part.get(), true);
316    }
317  }
318
   11. Condition !urlSpec, taking false branch
319  if (!urlSpec)
320    return NS_ERROR_OUT_OF_MEMORY;
321
   12. Condition options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay, taking true branch
   13. noescape: Resource urlSpec is not freed or pointed-to in strlen.
   14. noescape: Resource urlSpec is not freed or pointed-to in PL_strncasecmp.
   15. Condition PL_strncasecmp(aMessageURL, urlSpec, strlen(urlSpec)) == 0, taking true branch
322  if ((options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay) && (PL_strncasecmp(aMessageURL, urlSpec, strlen(urlSpec)) == 0))
   CID 1137478 (#3-2 of 3): Resource leak (RESOURCE_LEAK)16. leaked_storage: Variable urlSpec going out of scope leaks the storage it points to.
323    return NS_OK;
324

Observation: |urlSpec| is relased eventually on 
470  PR_FREEIF(urlSpec);
so we should insert PR_FREEIF(urlSpec) just before the early return on line 323.
You need to log in before you can comment on or make changes to this bug.