mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
Fix to allow proper calling with counts for wolfCrypt_Init
and wolfCrypt_Cleanup
. Old code was not tracking case such as wolfCrypt_Init
-> wolfCrypt_Init
-> wolfCrypt_Cleanup
and was causing cleanup to be performed, when it shouldn't.
This commit is contained in:
@ -206,9 +206,8 @@ int wolfCrypt_Init(void)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
initRefCount = 1;
|
|
||||||
}
|
}
|
||||||
|
initRefCount++;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -219,7 +218,11 @@ int wolfCrypt_Cleanup(void)
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (initRefCount == 1) {
|
initRefCount--;
|
||||||
|
if (initRefCount < 0)
|
||||||
|
initRefCount = 0;
|
||||||
|
|
||||||
|
if (initRefCount == 0) {
|
||||||
WOLFSSL_ENTER("wolfCrypt_Cleanup");
|
WOLFSSL_ENTER("wolfCrypt_Cleanup");
|
||||||
|
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
@ -250,7 +253,6 @@ int wolfCrypt_Cleanup(void)
|
|||||||
#if defined(WOLFSSL_CRYPTOCELL)
|
#if defined(WOLFSSL_CRYPTOCELL)
|
||||||
cc310_Free();
|
cc310_Free();
|
||||||
#endif
|
#endif
|
||||||
initRefCount = 0; /* allow re-init */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user