Fix things so DH_free() will be no-op when passed NULL, like RSA_free() and
[openssl.git] / crypto / asn1 / x_pubkey.c
index a70f53f..2177ebd 100644 (file)
@@ -183,7 +183,7 @@ EVP_PKEY *pkey;
                goto err;
                }
 
-       i=i2d_PublicKey(pkey,NULL);
+       if ((i=i2d_PublicKey(pkey,NULL)) <= 0) goto err;
        if ((s=(unsigned char *)Malloc(i+1)) == NULL) goto err;
        p=s;
        i2d_PublicKey(pkey,&p);