Ticket #856 (closed Bug: fixed)
[PATCH] Possible resource leak in ImagePreSaveHook.writeJpeg()
| Reported by: | Matthias Bauer <matthias.bauer.drs@…> | Owned by: | somebody |
|---|---|---|---|
| Priority: | Major | Milestone: | 2.5 |
| Component: | Repository | Version: | 2.4 |
| Keywords: | ImagePreSaveHook | Cc: |
Description
org.outerj.daisy.presavehook.image.ImagePreSaveHook?.writeJpeg() has some issues:
(1) There is probably a resource leak in that function, because the ImageWriter? needs to be a dispose()-d explicitly after use (at least according to the ImageIO documentation).
(2) writer.getDefaultWriteParam() is not guaranteed to return an instance of JPEGImageWriteParam. One should use ImageWriteParam? instead. (The JPEG-Writer of the JAI-ImageIO package for example returns an instance of its own parameter class, which is a child of ImageWriteParam?, but not one of JPEGImageWriteParam.)
(3) One should explicitly close the ImageOutputStream?. Some writers will return incomplete output, if the stream isn't flushed or closed.
ImagePreSaveHook?.01-Fix-WriteJpeg?.patch fixes these issues. I've also improved the error-handling a bit.
(While we are at it, one might also want to get rid of the obsoleted com.sun.image.codec.jpeg stuff. See ImagePreSaveHook?.02-Fix-Obsoletes.patch for this.)
Attachments
Change History
Changed 2 years ago by Matthias Bauer <matthias.bauer.drs@…>
- Attachment ImagePreSaveHook.01-Fix-WriteJpeg.patch added
Changed 2 years ago by Matthias Bauer <matthias.bauer.drs@…>
- Attachment ImagePreSaveHook.02-Fix-Obsoletes.patch added
patch to get rid of the obsoleted com.sun.image.codec.jpeg-stuff.
patch to fix the bugs in writeJpeg()