Remove pointless free, and use preferred way of calling d2i_* functions
authorMatt Caswell <matt@openssl.org>
Tue, 10 Feb 2015 16:21:30 +0000 (16:21 +0000)
committerMatt Caswell <matt@openssl.org>
Wed, 25 Feb 2015 17:13:24 +0000 (17:13 +0000)
Reviewed-by: Emilia Käsper <emilia@openssl.org>
crypto/ec/ec_asn1.c

index 1088e8916eff6aadca3fd3d773a057b9e4c20356..6ff94a356362e99d755efef3935f523377b23cdf 100644 (file)
@@ -1017,14 +1017,8 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len)
     EC_KEY *ret = NULL;
     EC_PRIVATEKEY *priv_key = NULL;
 
-    if ((priv_key = EC_PRIVATEKEY_new()) == NULL) {
-        ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_MALLOC_FAILURE);
-        return NULL;
-    }
-
-    if ((priv_key = d2i_EC_PRIVATEKEY(&priv_key, in, len)) == NULL) {
+    if ((priv_key = d2i_EC_PRIVATEKEY(NULL, in, len)) == NULL) {
         ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB);
-        EC_PRIVATEKEY_free(priv_key);
         return NULL;
     }