Commit 12eb88d981 for openssl.org
commit 12eb88d98117f26aabd72dd9da2b4fdc964378ad
Author: 609bob <1850029304@qq.com>
Date: Thu Oct 22 20:41:05 2026 +0800
crypto/asn1/d2i_pr.c: fix a dangling pointer in d2i_PrivateKey_legacy()
Fixes: b2952366dd02 "Fix d2i_PrivateKey_ex() to work as documented"
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Merge-date: Tue Nov 24 06:10:26 2026
Merged-from: https://github.com/openssl/openssl/pull/33317
diff --git a/crypto/asn1/d2i_pr.c b/crypto/asn1/d2i_pr.c
index 59ba8f909b..df7dd6c0a7 100644
--- a/crypto/asn1/d2i_pr.c
+++ b/crypto/asn1/d2i_pr.c
@@ -133,6 +133,8 @@ ossl_d2i_PrivateKey_legacy(int keytype, EVP_PKEY **a, const unsigned char **pp,
goto err;
}
EVP_PKEY_free(ret);
+ if (a != NULL)
+ *a = NULL;
ret = tmp;
ERR_pop_to_mark();
if (EVP_PKEY_type(keytype) != EVP_PKEY_get_base_id(ret))