[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1693-g893018e

[email protected] (Shailesh Mistry) Mon, 23 Sep 2019 16:51:22 +0000 (UTC)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, master has been updated
       via  893018e1c7aca3218555701208cc41daee34b8c4 (commit)
      from  adc3adfdf30f625444203a7c624c3fa123cfddd2 (commit)

----------------------------------------------------------------------
commit 893018e1c7aca3218555701208cc41daee34b8c4
Author: Shailesh Mistry <[email protected]>
Date:   Sun Sep 22 20:11:00 2019 +0100

    Bug 697545 : Prevent memory leaks in pcl_execute_macro.
    
    Prevent memory leaks on error.
    
    Error created using :-
    MEMENTO_FAILAT=15270 ./membin/gpcl6 -sDEVICE=pbmraw -o /dev/null ./tests_private/pcl/pcl5cfts/fts.1100

diff --git a/pcl/pcl/pcmacros.c b/pcl/pcl/pcmacros.c
index 5de0881..0dfbc52 100644
--- a/pcl/pcl/pcmacros.c
+++ b/pcl/pcl/pcmacros.c
@@ -90,15 +90,15 @@ pcl_execute_macro(const pcl_macro_t * pmac, pcl_state_t * pcs,
     r.limit = (const byte *)pmac + (gs_object_size(pcs->memory, pmac) - 1);
     pcs->macro_level++;
     code = pcl_process(&state, pcs, &r);
-    if (code < 0)
-        return code;
     pcs->macro_level--;
     if (after) {
-        code = do_copies(&saved, pcs, after);
-        if (code < 0)
-            return code;
+        int errcode = do_copies(&saved, pcs, after);
+        if (errcode < 0)
+            return errcode;
         memcpy(pcs, &saved, sizeof(*pcs));
     }
+    if (code < 0)
+        return code;
 #ifdef DEBUG
     if (gs_debug_c('i')) {
         pcl_dump_current_macro(pcs, "Finished macro execution");


Summary of changes:
 pcl/pcl/pcmacros.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)