Ticket #856 (closed Bug: fixed)

Opened 2 years ago

Last modified 19 months ago

[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

ImagePreSaveHook.01-Fix-WriteJpeg.patch (5.1 KB) - added by Matthias Bauer <matthias.bauer.drs@…> 2 years ago.
patch to fix the bugs in writeJpeg()
ImagePreSaveHook.02-Fix-Obsoletes.patch (5.6 KB) - added by Matthias Bauer <matthias.bauer.drs@…> 2 years ago.
patch to get rid of the obsoleted com.sun.image.codec.jpeg-stuff.

Change History

Changed 2 years ago by Matthias Bauer <matthias.bauer.drs@…>

patch to fix the bugs in writeJpeg()

Changed 2 years ago by Matthias Bauer <matthias.bauer.drs@…>

patch to get rid of the obsoleted com.sun.image.codec.jpeg-stuff.

comment:1 Changed 19 months ago by paul

  • Status changed from new to closed
  • Resolution set to fixed

In [5911]:

fixes #856. Apply patches by Matthias Bauer. Thanks

Note: See TracTickets for help on using tickets.