about summary refs log tree commit diff
path: root/converter/other/pngx.c
diff options
context:
space:
mode:
Diffstat (limited to 'converter/other/pngx.c')
-rw-r--r--converter/other/pngx.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/converter/other/pngx.c b/converter/other/pngx.c
index 602fdb33..22124b2a 100644
--- a/converter/other/pngx.c
+++ b/converter/other/pngx.c
@@ -69,6 +69,7 @@ pngx_create(struct pngx ** const pngxPP,
             else
                 *pngxPP = pngxP;
         }
+        pngxP->rw = rw;
     }
 }
 
@@ -77,7 +78,14 @@ pngx_create(struct pngx ** const pngxPP,
 void
 pngx_destroy(struct pngx * const pngxP) {
 
-    png_destroy_write_struct(&pngxP->png_ptr, &pngxP->info_ptr);
+    switch(pngxP->rw) {
+    case PNGX_READ:
+        png_destroy_read_struct(&pngxP->png_ptr, &pngxP->info_ptr, NULL);
+        break;
+    case PNGX_WRITE:
+        png_destroy_write_struct(&pngxP->png_ptr, &pngxP->info_ptr);
+        break;
+    }
 
     free(pngxP);
 }