about summary refs log tree commit diff
path: root/converter
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2019-08-29 20:36:35 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2019-08-29 20:36:35 +0000
commit061042409d376b8d7d3aeadbd6d46c2f34bde9cb (patch)
tree1f50cc0088b4e56e9c1501329401615fa5d3e981 /converter
parentad052df07fcf439b9b9097e552f017af86e7dec5 (diff)
downloadnetpbm-mirror-061042409d376b8d7d3aeadbd6d46c2f34bde9cb.tar.gz
netpbm-mirror-061042409d376b8d7d3aeadbd6d46c2f34bde9cb.tar.xz
netpbm-mirror-061042409d376b8d7d3aeadbd6d46c2f34bde9cb.zip
Fix memory leak
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3668 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter')
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_dec.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c b/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c
index cada97f8..0f162051 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c
@@ -1249,6 +1249,15 @@ static int jpc_dec_process_siz(jpc_dec_t *dec, jpc_ms_t *ms)
         return -1;
     }
 
+    for (tileno = 0, tile = dec->tiles;
+         tileno < dec->numtiles;
+         ++tileno, ++tile) {
+        /* initialize all tiles with JPC_TILE_DONE so jpc_dec_destroy() knows
+           which ones need a jpc_dec_tilefini() call; they are not actually
+           "done", of course */
+        tile->state = JPC_TILE_DONE;
+    }
+
     for (tileno = 0, tile = dec->tiles; tileno < dec->numtiles; ++tileno,
       ++tile) {
         htileno = tileno % dec->numhtiles;
@@ -1929,6 +1938,16 @@ static void jpc_dec_destroy(jpc_dec_t *dec)
     }
 
     if (dec->tiles) {
+        int tileno;
+        jpc_dec_tile_t *tile;
+
+        for (tileno = 0, tile = dec->tiles;
+             tileno < dec->numtiles;
+             ++tileno, ++tile) {
+            if (tile->state != JPC_TILE_DONE) {
+                jpc_dec_tilefini(dec, tile);
+            }
+        }
         jas_free(dec->tiles);
     }