scd: Avoid double-free on error condition in scd
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Fri, 19 Dec 2014 23:07:55 +0000 (18:07 -0500)
committerNIIBE Yutaka <gniibe@fsij.org>
Tue, 13 Jan 2015 01:52:22 +0000 (10:52 +0900)
* scd/command.c (cmd_readkey): avoid double-free of cert

--

When ksba_cert_new() fails, cert will be double-freed.

Debian-Bug-Id: 773471

Original patch changed by wk to do the free only at leave.

scd/command.c

index fc1f5a2..b26bd68 100644 (file)
@@ -777,10 +777,8 @@ cmd_readkey (assuan_context_t ctx, char *line)
 
   rc = ksba_cert_new (&kc);
   if (rc)
-    {
-      xfree (cert);
-      goto leave;
-    }
+    goto leave;
+
   rc = ksba_cert_init_from_mem (kc, cert, ncert);
   if (rc)
     {