File tree Expand file tree Collapse file tree 4 files changed +8
-13
lines changed Expand file tree Collapse file tree 4 files changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,8 @@ struct pkcs11_object_ops {
121
121
extern PKCS11_OBJECT_ops pkcs11_rsa_ops ;
122
122
extern PKCS11_OBJECT_ops pkcs11_ec_ops ;
123
123
124
+ extern int pkcs11_global_data_refs ;
125
+
124
126
/*
125
127
* Internal functions
126
128
*/
Original file line number Diff line number Diff line change @@ -811,7 +811,7 @@ EC_KEY_METHOD *PKCS11_get_ec_key_method(void)
811
811
812
812
void pkcs11_ec_key_method_free (void )
813
813
{
814
- if (pkcs11_ec_key_method ) {
814
+ if (pkcs11_global_data_refs == 0 && pkcs11_ec_key_method ) {
815
815
free_ec_ex_index ();
816
816
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER )
817
817
if (meth -> pkcs11_ecdh_method & EC_KEY_METHOD_DYNAMIC )
@@ -855,7 +855,7 @@ ECDSA_METHOD *PKCS11_get_ecdsa_method(void)
855
855
856
856
void pkcs11_ecdsa_method_free (void )
857
857
{
858
- if (pkcs11_ecdsa_method ) {
858
+ if (pkcs11_global_data_refs == 0 && pkcs11_ecdsa_method ) {
859
859
free_ec_ex_index ();
860
860
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER )
861
861
if (pkcs11_ecdsa_method -> flags & EC_KEY_METHOD_DYNAMIC )
@@ -881,7 +881,7 @@ ECDH_METHOD *PKCS11_get_ecdh_method(void)
881
881
882
882
void pkcs11_ecdh_method_free (void )
883
883
{
884
- if (pkcs11_ecdh_method ) {
884
+ if (pkcs11_global_data_refs == 0 && pkcs11_ecdh_method ) {
885
885
free_ec_ex_index ();
886
886
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER )
887
887
if (pkcs11_ecdh_method -> flags & EC_KEY_METHOD_DYNAMIC )
Original file line number Diff line number Diff line change 20
20
#include <string.h>
21
21
22
22
/* Global number of active PKCS11_CTX objects */
23
- static int pkcs11_global_data_refs = 0 ;
24
-
25
- static void pkcs11_global_data_free (void );
23
+ int pkcs11_global_data_refs = 0 ;
26
24
27
25
/*
28
26
* Create a new context
@@ -177,12 +175,7 @@ void pkcs11_CTX_free(PKCS11_CTX *ctx)
177
175
OPENSSL_free (ctx -> _private );
178
176
OPENSSL_free (ctx );
179
177
180
- if (-- pkcs11_global_data_refs == 0 )
181
- pkcs11_global_data_free ();
182
- }
183
-
184
- static void pkcs11_global_data_free (void )
185
- {
178
+ pkcs11_global_data_refs -- ;
186
179
#ifndef OPENSSL_NO_RSA
187
180
pkcs11_rsa_method_free ();
188
181
#endif
Original file line number Diff line number Diff line change @@ -545,7 +545,7 @@ RSA_METHOD *PKCS11_get_rsa_method(void)
545
545
546
546
void pkcs11_rsa_method_free (void )
547
547
{
548
- if (pkcs11_rsa_method ) {
548
+ if (pkcs11_global_data_refs == 0 && pkcs11_rsa_method ) {
549
549
free_rsa_ex_index ();
550
550
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
551
551
RSA_meth_free (pkcs11_rsa_method );
You can’t perform that action at this time.
0 commit comments