[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1673-gc917d64

[email protected] (Ray Johnston)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, master has been updated
       via  c917d64d73fae679d445b233662e0ef4480078f6 (commit)
       via  d79d17251261637b672f8518144ffffc42e1eb0e (commit)
      from  8b0ed52ead9605cae14939362dbf9cdf22b9746c (commit)

----------------------------------------------------------------------
commit c917d64d73fae679d445b233662e0ef4480078f6
Author: Ray Johnston <[email protected]>
Date:   Wed Sep 11 14:10:27 2019 -0700

    Fix Bug 696333. Allow large bitmaps in clist when writing tile cache.
    
    When writing bits to update the tile cache, we don't need to restrict to
    a single command buffer as with the copy_mono and copy_color commands.
    
    Progressions on:
    tests_private/comparefiles/Bug694385.pdf.psdcmyk.300.1..gs
    tests_private/pdf/sumatra/2028_-_invisible_patterns.pdf.psdcmyk.300.1..gs
    tests_private/ps/ps3cet/09-47B.PS.pdf.pkmraw.300.0..gs_pdf
    tests_private/ps/ps3fts/176-01.ps.psdcmyk.300.1..gs

diff --git a/base/gxclbits.c b/base/gxclbits.c
index 5572b1f..0d2b46f 100644
--- a/base/gxclbits.c
+++ b/base/gxclbits.c
@@ -150,6 +150,7 @@ cmd_compress_bitmap(stream_state * st, const byte * data, uint width_bits,
  * Return <0 if error, otherwise the compression method.
  * A return value of gs_error_limitcheck means that the bitmap was too big
  * to fit in the command reading buffer.
+ * This won't happen if the compression_mask has allow_large_bitmap set.
  * Note that this leaves room for the command and initial arguments,
  * but doesn't fill them in.
  */
@@ -159,15 +160,14 @@ cmd_put_bits(gx_device_clist_writer * cldev, gx_clist_state * pcls,
              int compression_mask, byte ** pdp, uint * psize)
 {
     uint short_raster, full_raster;
-    uint short_size =
-    clist_bitmap_bytes(width_bits, height,
-                       compression_mask & ~cmd_mask_compress_any,
-                       &short_raster, &full_raster);
+    uint short_size = clist_bitmap_bytes(width_bits, height,
+                          compression_mask & ~cmd_mask_compress_any,
+                          &short_raster, &full_raster);
     uint uncompressed_raster;
-    uint uncompressed_size =
-    clist_bitmap_bytes(width_bits, height, compression_mask,
+    uint uncompressed_size = clist_bitmap_bytes(width_bits, height, compression_mask,
                        &uncompressed_raster, &full_raster);
-    uint max_size = data_bits_size - op_size;
+    uint max_size = (compression_mask & allow_large_bitmap) ? 0x7fffffff :
+                        data_bits_size - op_size;
     gs_memory_t *mem = cldev->memory;
     byte *dp;
     int compress = 0;
@@ -699,13 +699,15 @@ clist_change_tile(gx_device_clist_writer * cldev, gx_clist_state * pcls,
                 if (tiles->num_planes != 1)
                     pdepth /= tiles->num_planes;
 
+                /* put the bits, but don't restrict to a single buffer */
                 code = cmd_put_bits(cldev, pcls, ts_bits(cldev, loc.tile),
                                     tiles->rep_width * pdepth,
                                     tiles->rep_height * tiles->num_planes,
                                     loc.tile->cb_raster, rsize,
-                                    (cldev->tile_params.size.x > tiles->rep_width ?
-                                     decompress_elsewhere | decompress_spread :
-                                     decompress_elsewhere),
+                                    allow_large_bitmap |
+                                        (cldev->tile_params.size.x > tiles->rep_width ?
+                                             decompress_elsewhere | decompress_spread :
+                                             decompress_elsewhere),
                                     &dp, &csize);
 
                 if (code < 0)
@@ -790,11 +792,13 @@ clist_change_bits(gx_device_clist_writer * cldev, gx_clist_state * pcls,
                     pdepth /= loc.tile->num_planes;
             if (loc.tile->num_bands == CHAR_ALL_BANDS_COUNT)
                 bit_pcls = NULL;
+            /* put the bits, but don't restrict to a single buffer */
             code = cmd_put_bits(cldev, bit_pcls, ts_bits(cldev, loc.tile),
                                 loc.tile->width * pdepth,
                                 loc.tile->height * loc.tile->num_planes, loc.tile->cb_raster,
                                 rsize,
-                              decompress_elsewhere | (cldev->target->BLS_force_memory ? (1 << cmd_compress_cfe) : 0),
+                                decompress_elsewhere |
+                                    (cldev->target->BLS_force_memory ? (1 << cmd_compress_cfe) : 0),
                                 &dp, &csize);
 
             if (code < 0)
diff --git a/base/gxcldev.h b/base/gxcldev.h
index 84bfd42..19d19bc 100644
--- a/base/gxcldev.h
+++ b/base/gxcldev.h
@@ -42,6 +42,7 @@
 #define cmd_compress_const 3
 #define cmd_mask_compress_any\
   ((1 << cmd_compress_rle) | (1 << cmd_compress_cfe) | (1 << cmd_compress_const))
+
 /* Exported by gxclutil.c */
 void clist_rle_init(stream_RLE_state *ss);
 void clist_rld_init(stream_RLD_state *ss);
@@ -594,6 +595,10 @@ int cmd_write_page_rect_cmd(gx_device_clist_writer * cldev, int op);
  */
 #define decompress_spread 0x200
 
+/* clist_copy_mono and clist_copy_color have a max_size, but tiles to the */
+/* cache do not (clist_change_bits and clist_change_tile).		  */
+#define allow_large_bitmap 0x400
+
 int cmd_put_bits(gx_device_clist_writer * cldev, gx_clist_state * pcls,
                  const byte * data, uint width_bits, uint height,
                  uint raster, int op_size, int compression_mask,
diff --git a/base/gxclrect.c b/base/gxclrect.c
index a4b5982..1eaa391 100644
--- a/base/gxclrect.c
+++ b/base/gxclrect.c
@@ -1541,7 +1541,7 @@ clist_strip_copy_rop2(gx_device * dev,
                         tile_with_id.id = gs_next_ids(dev->memory, 1);
                         tiles = &tile_with_id;
                     }
-                    code = clist_change_tile(cdev, re.pcls, tiles,
+                    code = clist_change_bits(cdev, re.pcls, tiles,
                                             (tcolors != 0 ? 1 :
                                                  cdev->clist_color_info.depth));
                     if (code < 0 && !(code == gs_error_limitcheck))

----------------------------------------------------------------------
commit d79d17251261637b672f8518144ffffc42e1eb0e
Author: Ray Johnston <[email protected]>
Date:   Thu Sep 12 10:37:42 2019 -0700

    Fix SEGV with flp device and PCL with clist mode and large BandHeight.
    
    If the 'clist_init' fails initially (with rangecheck) due to the buffer
    space too small for the BandHeight specified, we loop in the caller after
    increasing the buffer size, but clist_init left "is_open" false when failing.
    Add save_is_open in gdev_prn_setup_as_command_list so that we can restore it
    if the clist_init eventually suceeds.
    
    The SEGV was with image_data because re-opening the flp device reset the
    "obsolete" procs to the default, so flp_image_data was replaced by the
    gx_default_image_data, but no begin_image had been performed (flp_begin_image
    skipped this since we were not yet at the FirstPage).

diff --git a/base/gdevprn.c b/base/gdevprn.c
index b945428..3518ce6 100644
--- a/base/gdevprn.c
+++ b/base/gdevprn.c
@@ -233,6 +233,7 @@ gdev_prn_setup_as_command_list(gx_device *pdev, gs_memory_t *buffer_memory,
     gx_device_clist_common * const pcldev = &pclist_dev->common;
     bool reallocate = *the_memory != 0;
     byte *base;
+    bool save_is_open = pdev->is_open;	/* Save around temporary failure in open_c loop */
 
     while (target->parent != NULL) {
         target = target->parent;
@@ -303,8 +304,10 @@ open_c:
                                    "cmd list buf(retry open)");
             }
             ppdev->buf = *the_memory;
-            if (base != 0)
+            if (base != 0) {
+                pdev->is_open = save_is_open;	/* allow for success when we loop */
                 goto open_c;
+            }
         }
         /* Failure. */
         if (!reallocate) {
diff --git a/base/gxclist.c b/base/gxclist.c
index 07ed6e9..14b825c 100644
--- a/base/gxclist.c
+++ b/base/gxclist.c
@@ -703,19 +703,22 @@ clist_open(gx_device *dev)
 
     code = clist_init(dev);
     if (code < 0)
-        return code;
+        goto errxit;
+
     cdev->icc_cache_list_len = 0;
     cdev->icc_cache_list = NULL;
     code = clist_open_output_file(dev);
     if ( code >= 0)
         code = clist_emit_page_header(dev);
     if (code >= 0) {
-       dev->is_open = save_is_open;
-    } else {
-        gs_free_object(cdev->memory->non_gc_memory, cdev->cache_chunk, "free tile cache for clist");
-        cdev->cache_chunk = NULL;
+        dev->is_open = save_is_open;
+        return code;		/* success */
     }
-
+    /* fall through to clean up and return error code */
+errxit:
+    /* prevent leak */
+    gs_free_object(cdev->memory->non_gc_memory, cdev->cache_chunk, "free tile cache for clist");
+    cdev->cache_chunk = NULL;
     return code;
 }
 


Summary of changes:
 base/gdevprn.c  |  5 ++++-
 base/gxclbits.c | 26 +++++++++++++++-----------
 base/gxcldev.h  |  5 +++++
 base/gxclist.c  | 15 +++++++++------
 base/gxclrect.c |  2 +-
 5 files changed, 34 insertions(+), 19 deletions(-)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.