fix freeing a failed RNG

This commit is contained in:
John Safranek 2015-03-06 09:51:29 -08:00
parent d5975e39f8
commit 874fa8c1f9

View File

@ -507,13 +507,16 @@ int wc_FreeRng(RNG* rng)
int ret = BAD_FUNC_ARG;
if (rng != NULL) {
if (Hash_DRBG_Uninstantiate(rng->drbg) == DRBG_SUCCESS)
ret = 0;
else
ret = RNG_FAILURE_E;
if (rng->drbg != NULL) {
if (Hash_DRBG_Uninstantiate(rng->drbg) == DRBG_SUCCESS)
ret = 0;
else
ret = RNG_FAILURE_E;
XFREE(rng->drbg, NULL, DYNAMIC_TYPE_RNG);
rng->drbg = NULL;
}
XFREE(rng->drbg, NULL, DYNAMIC_TYPE_RNG);
rng->drbg = NULL;
rng->status = DRBG_NOT_INIT;
}