gpg: Add standard free() semantic to pubkey_free.
authorWerner Koch <wk@gnupg.org>
Wed, 23 Dec 2015 14:17:50 +0000 (15:17 +0100)
committerWerner Koch <wk@gnupg.org>
Wed, 23 Dec 2015 14:17:50 +0000 (15:17 +0100)
* g10/getkey.c (pubkey_free): Check for NULL arg.
--

We don't like surprises ;-)

Signed-off-by: Werner Koch <wk@gnupg.org>
g10/getkey.c

index a32e729..26b1932 100644 (file)
@@ -369,9 +369,12 @@ getkey_disable_caches ()
 void
 pubkey_free (struct pubkey *key)
 {
-  xfree (key->pk);
-  release_kbnode (key->keyblock);
-  xfree (key);
+  if (key)
+    {
+      xfree (key->pk);
+      release_kbnode (key->keyblock);
+      xfree (key);
+    }
 }
 
 void