Prevent double-free of CTLOG public key
authorRob Percival <robpercival@google.com>
Tue, 23 Aug 2016 15:55:09 +0000 (16:55 +0100)
committerMatt Caswell <matt@openssl.org>
Tue, 23 Aug 2016 19:17:14 +0000 (20:17 +0100)
Previously, if ct_v1_log_id_from_pkey failed, public_key would be freed by
CTLOG_free at the end of the function, and then again by the caller (who
would assume ownership was not transferred when CTLOG_new returned NULL).

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
crypto/ct/ct_log.c

index 13f7f3914817c5de3f04573fc5264c398e93e1ad..6db4c3eba12084326131a7b9b3028c8c6893537f 100644 (file)
@@ -247,10 +247,10 @@ CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name)
         goto err;
     }
 
-    ret->public_key = public_key;
     if (ct_v1_log_id_from_pkey(public_key, ret->log_id) != 1)
         goto err;
 
+    ret->public_key = public_key;
     return ret;
 err:
     CTLOG_free(ret);