[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1682-g0b05dca

[email protected] (Shailesh Mistry)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, master has been updated
       via  0b05dca78aaa456ba7b55b853917a4ae68a6fd38 (commit)
      from  f40631e7592ed1287b2121840b3345acb1bdb1a8 (commit)

----------------------------------------------------------------------
commit 0b05dca78aaa456ba7b55b853917a4ae68a6fd38
Author: Shailesh Mistry <[email protected]>
Date:   Mon Sep 16 11:32:33 2019 +0100

    Bug 697545 : Prevent memory leaks in show_char_background.
    
    Prevent memory leaks on error and then later releasing graphic state.
    
    Error created using :-
    MEMENTO_FAILAT=15988 ./membin/gpcl6 -sDEVICE=pbmraw -o /dev/null ./tests_private/pcl/pcl5cfts/fts.0891

diff --git a/pcl/pcl/pctext.c b/pcl/pcl/pctext.c
index 64a1f44..cc5da2f 100644
--- a/pcl/pcl/pctext.c
+++ b/pcl/pcl/pctext.c
@@ -618,8 +618,10 @@ show_char_background(pcl_state_t * pcs, const gs_char * pbuff)
         return code;
     if (pcs->pattern_transparent) {
         code = pcl_set_drawing_color(pcs, pcl_pattern_solid_white, 0, false);
-        if (code < 0)
+        if (code < 0) {
+            (void)pcl_grestore(pcs);
             return code;
+        }
     }
     if (((code = gs_setrasterop(pgs, (gs_rop3_t) rop3_know_S_1((int)rop))) < 0) ||
         ((code = gs_currentpoint(pgs, &pt)) < 0)) {
@@ -645,7 +647,7 @@ show_char_background(pcl_state_t * pcs, const gs_char * pbuff)
             gs_image_enum_alloc(gs_gstate_memory(pgs),
                                 "bitmap font background");
         if (pen == 0) {
-            pcl_grestore(pcs);
+            (void)pcl_grestore(pcs);
             return e_Memory;
         }
 
@@ -670,11 +672,12 @@ show_char_background(pcl_state_t * pcs, const gs_char * pbuff)
     } else {
         gs_text_params_t text;
         gs_rect bbox;
-        gs_text_enum_t *penum;
+        gs_text_enum_t *penum = NULL;
 
         /* clear the path; start the new one from the current point */
         if (((code = gs_newpath(pgs)) < 0) ||
             ((code = gs_moveto(pgs, pt.x, pt.y)) < 0)) {
+            (void)pcl_grestore(pcs);
             return code;
         }
         text.data.chars = pbuff;
@@ -690,10 +693,13 @@ show_char_background(pcl_state_t * pcs, const gs_char * pbuff)
                 (code = gs_rectappend(pgs, &bbox, 1)) >= 0 &&
                 (code = gs_eofill(pgs)) >= 0)
             {
-                gs_text_release(penum, "show_char_background");
+                /* fall through */
             }
-            else
-                return code;
+        }
+        gs_text_release(penum, "show_char_background");
+        if (code < 0) {
+            (void)pcl_grestore(pcs);
+            return code;
         }
     }
 


Summary of changes:
 pcl/pcl/pctext.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 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.