g10: Push compress filter only if compressed.
authorNIIBE Yutaka <gniibe@fsij.org>
Fri, 13 Apr 2018 01:09:02 +0000 (10:09 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Fri, 13 Apr 2018 01:09:02 +0000 (10:09 +0900)
* g10/compress.c (handle_compressed): Fix memory leak.

--

All other calls of push_compress_filter checks ALGO,
so, do it here, too.

GnuPG-bug-id: 3898
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
g10/compress.c

index 61bb756..67c9c9b 100644 (file)
@@ -309,15 +309,18 @@ int
 handle_compressed (ctrl_t ctrl, void *procctx, PKT_compressed *cd,
                   int (*callback)(IOBUF, void *), void *passthru )
 {
-    compress_filter_context_t *cfx;
     int rc;
 
     if(check_compress_algo(cd->algorithm))
       return GPG_ERR_COMPR_ALGO;
-    cfx = xmalloc_clear (sizeof *cfx);
-    cfx->release = release_context;
-    cfx->algo = cd->algorithm;
-    push_compress_filter(cd->buf,cfx,cd->algorithm);
+    if(cd->algorithm) {
+        compress_filter_context_t *cfx;
+
+        cfx = xmalloc_clear (sizeof *cfx);
+        cfx->release = release_context;
+        cfx->algo = cd->algorithm;
+        push_compress_filter(cd->buf,cfx,cd->algorithm);
+    }
     if( callback )
        rc = callback(cd->buf, passthru );
     else