evp: fix coverity 1473378: unchecked return value
authorPauli <ppzgs1@gmail.com>
Thu, 18 Mar 2021 23:43:24 +0000 (09:43 +1000)
committerPauli <pauli@openssl.org>
Thu, 25 Mar 2021 22:46:02 +0000 (08:46 +1000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14615)

crypto/evp/p_lib.c

index 4abecdf30c356629632e80754c9c28bfd11eaf12..94a83c48041384295cf59491f71fa6374052aa08 100644 (file)
@@ -846,8 +846,9 @@ static const ECX_KEY *evp_pkey_get0_ECX_KEY(const EVP_PKEY *pkey, int type)
 static ECX_KEY *evp_pkey_get1_ECX_KEY(EVP_PKEY *pkey, int type)
 {
     ECX_KEY *ret = (ECX_KEY *)evp_pkey_get0_ECX_KEY(pkey, type);
-    if (ret != NULL)
-        ossl_ecx_key_up_ref(ret);
+
+    if (ret != NULL && !ossl_ecx_key_up_ref(ret))
+        ret = NULL;
     return ret;
 }