X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fec%2Fec_key.c;h=1352cbe81fa56b1806a38e22c27e1fc8da148fa4;hp=387455317910dfb1dd0ad9aea000250d877f3c2b;hb=cdb10bae3f773401e039c55965eb177a6f3fc160;hpb=29f484d00d732ea4c19a7fd3dc0440045653e79e diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c index 3874553179..1352cbe81f 100644 --- a/crypto/ec/ec_key.c +++ b/crypto/ec/ec_key.c @@ -613,12 +613,14 @@ size_t EC_KEY_priv2buf(const EC_KEY *eckey, unsigned char **pbuf) { size_t len; unsigned char *buf; + len = EC_KEY_priv2oct(eckey, NULL, 0); if (len == 0) return 0; - buf = OPENSSL_malloc(len); - if (buf == NULL) + if ((buf = OPENSSL_malloc(len)) == NULL) { + ECerr(EC_F_EC_KEY_PRIV2BUF, ERR_R_MALLOC_FAILURE); return 0; + } len = EC_KEY_priv2oct(eckey, buf, len); if (len == 0) { OPENSSL_free(buf);