coverity #1486531: return error properly from x509_pubkey_ex_new_ex()
authorTomas Mraz <tomas@openssl.org>
Mon, 28 Jun 2021 15:09:08 +0000 (17:09 +0200)
committerTomas Mraz <tomas@openssl.org>
Tue, 29 Jun 2021 16:41:45 +0000 (18:41 +0200)
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15942)

crypto/x509/x_pubkey.c

index b20b756e9a526e471728f754382d976966fdc466..0c07c39a1f284d3d48632de3e7aa2c880219b22c 100644 (file)
@@ -116,6 +116,7 @@ static int x509_pubkey_ex_new_ex(ASN1_VALUE **pval, const ASN1_ITEM *it,
         || !x509_pubkey_ex_populate((ASN1_VALUE **)&ret, NULL)
         || !x509_pubkey_set0_libctx(ret, libctx, propq)) {
         x509_pubkey_ex_free((ASN1_VALUE **)&ret, NULL);
+        ret = NULL;
         ERR_raise(ERR_LIB_ASN1, ERR_R_MALLOC_FAILURE);
     } else {
         *pval = (ASN1_VALUE *)ret;