Bug 691296

Summary: Missing NULL check in bbox_close_device()
Product: Ghostscript Reporter: Tim Waugh <twaugh>
Component: GeneralAssignee: Ray Johnston <ray.johnston>
Status: RESOLVED FIXED    
Severity: blocker CC: chris.liddell, christinedelight.top85
Priority: P1    
Version: unspecified   
Hardware: PC   
OS: Linux   
Customer: Word Size: ---
Attachments: ghostscript-bbox-close.patch
www.ti.com/ww/en/analog/led/slyt394a.pdf

Description Tim Waugh 2010-05-13 16:09:05 UTC
Created attachment 6277 [details]
ghostscript-bbox-close.patch

When bbox_close_device() is called on a compositor wrapper bbox, there is no check before calling gs_closedevice on the target device.

Original bug report:
  https://bugzilla.redhat.com/show_bug.cgi?id=591624
Comment 1 Hin-Tak Leung 2010-05-13 16:56:15 UTC
Patch looks "obviously" correct and committed as r11235 . But it is a bit worrying that the target device is NULL there  (it shouldn't be). So leave this bug open when we find the regression and re-assign.
Comment 2 Hin-Tak Leung 2010-05-13 17:08:33 UTC
Created attachment 6278 [details]
www.ti.com/ww/en/analog/led/slyt394a.pdf

The test file (just in case it disappears off the internet).

Page 1 has a problem:

Processing pages 1 through 64.
Page 1
jasper (code 0) write component failed
jasper (code 0) error: cannot decode code stream
unable to decode JPX image data.

Luratech decoder can process it.

But regardless, page two crashes both jasper and luratech binaries, so is unrelated.
Comment 3 Hin-Tak Leung 2010-05-15 09:32:48 UTC
Reassign to author of the problematic patch from git-bisect:

r10369 | ray | 2009-11-23 17:35:16 +0000 (Mon, 23 Nov 2009) | 32 lines

Fix for segfault reported in 690880 with separation devices. The is_open flag
was not being properly maintained when put_params resulted in a target device
closing due to DeviceN color state changing.

This commit causes a regression with crash with the attached test file.
Comment 4 Ray Johnston 2017-10-16 13:10:29 UTC
Tested with 9.22 and the command line:

gs Bug691296.pdf

Command line not given, but due to reference to the bbox device, I deduce
that the default x11 device (on linux) was used.

This works for me no problem. Note that we now use openjpeg, which also
complains on page 1 with:
    openjpeg warning: Non conformant codestream TPsot==TNsot.
but no crash/segfault occurs.

I assume this has been fixed.