Bug 695543 - gs %stdin segfaults
authorChris Liddell <chris.liddell@artifex.com>
Sat, 27 Sep 2014 08:05:54 +0000 (09:05 +0100)
committerChris Liddell <chris.liddell@artifex.com>
Sat, 27 Sep 2014 08:20:32 +0000 (09:20 +0100)
In zopen_file() when we're opening a Postscript device, ensure that we set the
"state" entry in the iodev structure before calling the device specific "open"
method - as we do elsewhere in the same circumstances. That is required to
properly access devices like "%stdin" and co.

No cluster differences.

gs/psi/zfile.c

index e092bed9c2275b5bceb73f5fcd0e59863382891c..0c0468443f3b8c6a9109243870ac6357825775d0 100644 (file)
@@ -858,8 +858,11 @@ zopen_file(i_ctx_t *i_ctx_p, const gs_parsed_file_name_t *pfn,
 {
     gx_io_device *const iodev = pfn->iodev;
 
-    if (pfn->fname == NULL)     /* just a device */
+    if (pfn->fname == NULL) {     /* just a device */
+        iodev->state = i_ctx_p;
         return iodev->procs.open_device(iodev, file_access, ps, mem);
+        iodev->state = NULL;
+    }
     else {                      /* file */
         iodev_proc_open_file((*open_file)) = iodev->procs.open_file;