]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[Core] Better handle error cases in switch_rand(). 2482/head
authorAndrey Volk <andywolk@gmail.com>
Fri, 7 Jun 2024 13:07:15 +0000 (16:07 +0300)
committerAndrey Volk <andywolk@gmail.com>
Fri, 7 Jun 2024 20:12:20 +0000 (23:12 +0300)
src/switch_utils.c

index 25d0bf76eef5309dee1d4a0176e5a9af30f7a70c..64577d3997d29a03dbbe372a907179efdd2a8ff0 100644 (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;
        }