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; int ret = BAD_FUNC_ARG;
if (rng != NULL) { if (rng != NULL) {
if (Hash_DRBG_Uninstantiate(rng->drbg) == DRBG_SUCCESS) if (rng->drbg != NULL) {
ret = 0; if (Hash_DRBG_Uninstantiate(rng->drbg) == DRBG_SUCCESS)
else ret = 0;
ret = RNG_FAILURE_E; 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; rng->status = DRBG_NOT_INIT;
} }