[Core] Better handle error cases in switch_rand().

This commit is contained in:
Andrey Volk 2024-06-07 16:07:15 +03:00
parent 99625acfa9
commit 9f362ea315
1 changed files with 4 additions and 0 deletions

View File

@ -4828,6 +4828,8 @@ SWITCH_DECLARE(int) switch_rand(void)
if (!BCRYPT_SUCCESS(status)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "BCryptGenRandom failed with status %d\n", status);
BCryptCloseAlgorithmProvider(hAlgorithm, 0);
return 1;
}
@ -4856,6 +4858,8 @@ SWITCH_DECLARE(int) switch_rand(void)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "read failed: %s\n", error_msg);
close(random_fd);
return 1;
}