From: Andrey Volk Date: Fri, 7 Jun 2024 13:07:15 +0000 (+0300) Subject: [Core] Better handle error cases in switch_rand(). X-Git-Tag: v1.10.12^2~29^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2482%2Fhead;p=thirdparty%2Ffreeswitch.git [Core] Better handle error cases in switch_rand(). --- diff --git a/src/switch_utils.c b/src/switch_utils.c index 25d0bf76ee..64577d3997 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -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; }