[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1861-g51aff03

[email protected] (Chris Liddell) Thu, 14 Nov 2019 15:28:15 +0000 (UTC)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, master has been updated
       via  51aff033bdc8744adfd86ce8b35ef00f23621de2 (commit)
      from  33f4f0c0ba5449fd535061e785090bc57849ae51 (commit)

----------------------------------------------------------------------
commit 51aff033bdc8744adfd86ce8b35ef00f23621de2
Author: Chris Liddell <[email protected]>
Date:   Thu Nov 14 13:22:11 2019 +0000

    Bug 701903: (ps2write) clean up image enumerator streams.
    
    At the end of an image (especially if the "end" is because of an error
    condition) make sure we clean up any streams created for the handling of the
    image data.
    
    This saves leaving the streams around for gc to cleanup, and avoids a problem
    where a special purpose stream (for color images) holds a reference to a
    color space and graphics state either or both of which could be freed by a
    Postscript restore before the garbager gets called to deal with unreferenced
    objects.

diff --git a/devices/vector/gdevpdfi.c b/devices/vector/gdevpdfi.c
index fed96e4..2f9cea0 100644
--- a/devices/vector/gdevpdfi.c
+++ b/devices/vector/gdevpdfi.c
@@ -1878,7 +1878,7 @@ pdf_image_end_image_data(gx_image_enum_common_t * info, bool draw_last,
     pdf_image_enum *pie = (pdf_image_enum *)info;
     int height = pie->writer.height;
     int data_height = height - pie->rows_left;
-    int code = 0;
+    int code = 0, ecode;
 
     if (pie->writer.pres)
         ((pdf_x_object_t *)pie->writer.pres)->data_height = data_height;
@@ -1920,6 +1920,12 @@ pdf_image_end_image_data(gx_image_enum_common_t * info, bool draw_last,
     if (pie->initial_colorspace != pdev->pcm_color_info_index)
         pdf_set_process_color_model(pdev, pie->initial_colorspace);
 
+    /* Clean up any outstanding streams before freeing the enumerator */
+    while (pie->writer.alt_writer_count-- > 0) {
+        ecode = psdf_end_binary(&(pie->writer.binary[pie->writer.alt_writer_count]));
+        if (ecode < 0 && code >= 0) code  = ecode;
+    }
+
     gx_image_free_enum(&info);
     return code;
 }


Summary of changes:
 devices/vector/gdevpdfi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)