summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/evp/p_lib.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/lib/libcrypto/evp/p_lib.c b/src/lib/libcrypto/evp/p_lib.c
index f819717cbc..3eba5af298 100644
--- a/src/lib/libcrypto/evp/p_lib.c
+++ b/src/lib/libcrypto/evp/p_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p_lib.c,v 1.46 2023/12/25 21:37:26 tb Exp $ */ 1/* $OpenBSD: p_lib.c,v 1.47 2023/12/25 21:41:19 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -225,21 +225,17 @@ evp_pkey_free_pkey_ptr(EVP_PKEY *pkey)
225} 225}
226 226
227void 227void
228EVP_PKEY_free(EVP_PKEY *x) 228EVP_PKEY_free(EVP_PKEY *pkey)
229{ 229{
230 int i; 230 if (pkey == NULL)
231
232 if (x == NULL)
233 return; 231 return;
234 232
235 i = CRYPTO_add(&x->references, -1, CRYPTO_LOCK_EVP_PKEY); 233 if (CRYPTO_add(&pkey->references, -1, CRYPTO_LOCK_EVP_PKEY) > 0)
236 if (i > 0)
237 return; 234 return;
238 235
239 evp_pkey_free_pkey_ptr(x); 236 evp_pkey_free_pkey_ptr(pkey);
240 if (x->attributes) 237 sk_X509_ATTRIBUTE_pop_free(pkey->attributes, X509_ATTRIBUTE_free);
241 sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free); 238 freezero(pkey, sizeof(*pkey));
242 free(x);
243} 239}
244 240
245/* Setup a public key ASN1 method from a NID or a string. 241/* Setup a public key ASN1 method from a NID or a string.