sm: Avoid double-free on iconv failure
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Fri, 19 Dec 2014 23:53:34 +0000 (18:53 -0500)
committerNIIBE Yutaka <gniibe@fsij.org>
Tue, 13 Jan 2015 01:52:22 +0000 (10:52 +0900)
* sm/minip12.c: (p12_build) if jnlib_iconv_open fails, avoid
double-free of pwbuf.

--

Observed by Joshua Rogers <honey@internot.info>, who proposed a
slightly different fix.

Debian-Bug-Id: 773472

Added fix at a second place - wk.

agent/minip12.c

index 2471717..0bcab5f 100644 (file)
@@ -2182,6 +2182,7 @@ p12_build (gcry_mpi_t *kparms, unsigned char *cert, size_t certlen,
                      " requested charset `%s': %s\n",
                      charset, strerror (errno));
           gcry_free (pwbuf);
+          pwbuf = NULL;
           goto failure;
         }
 
@@ -2196,6 +2197,7 @@ p12_build (gcry_mpi_t *kparms, unsigned char *cert, size_t certlen,
                      " requested charset `%s': %s\n",
                      charset, strerror (errno));
           gcry_free (pwbuf);
+          pwbuf = NULL;
           jnlib_iconv_close (cd);
           goto failure;
         }