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)
committerWerner Koch <wk@gnupg.org>
Mon, 22 Dec 2014 12:17:50 +0000 (13:17 +0100)
* 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 dd4191f..1cc580a 100644 (file)
@@ -804,10 +804,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)
     {