From: tb Date: Mon, 25 Dec 2023 21:37:26 +0000 (+0000) Subject: Move EVP_PKEY_free() up next to evp_pkey_free_pkey_ptr() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=543ad17db49fca32cf36d906a339dafc9907c05c;p=openbsd Move EVP_PKEY_free() up next to evp_pkey_free_pkey_ptr() ok jsing --- diff --git a/lib/libcrypto/evp/p_lib.c b/lib/libcrypto/evp/p_lib.c index 6cecad20d46..f819717cbcb 100644 --- a/lib/libcrypto/evp/p_lib.c +++ b/lib/libcrypto/evp/p_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_lib.c,v 1.45 2023/12/25 21:36:05 tb Exp $ */ +/* $OpenBSD: p_lib.c,v 1.46 2023/12/25 21:37:26 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -224,6 +224,24 @@ evp_pkey_free_pkey_ptr(EVP_PKEY *pkey) pkey->pkey.ptr = NULL; } +void +EVP_PKEY_free(EVP_PKEY *x) +{ + int i; + + if (x == NULL) + return; + + i = CRYPTO_add(&x->references, -1, CRYPTO_LOCK_EVP_PKEY); + if (i > 0) + return; + + evp_pkey_free_pkey_ptr(x); + if (x->attributes) + sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free); + free(x); +} + /* Setup a public key ASN1 method from a NID or a string. * If pkey is NULL just return 1 or 0 if the algorithm exists. */ @@ -582,24 +600,6 @@ EVP_PKEY_base_id(const EVP_PKEY *pkey) return EVP_PKEY_type(pkey->type); } -void -EVP_PKEY_free(EVP_PKEY *x) -{ - int i; - - if (x == NULL) - return; - - i = CRYPTO_add(&x->references, -1, CRYPTO_LOCK_EVP_PKEY); - if (i > 0) - return; - - evp_pkey_free_pkey_ptr(x); - if (x->attributes) - sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free); - free(x); -} - static int unsup_alg(BIO *out, const EVP_PKEY *pkey, int indent, const char *kstr) {