Commit: patch 9.1.0531: resource leak in mch_get_random()

14 views
Skip to first unread message

Christian Brabandt

unread,
Jul 5, 2024, 4:00:16 AM7/5/24
to vim...@googlegroups.com
patch 9.1.0531: resource leak in mch_get_random()

Commit: https://github.com/vim/vim/commit/93a3d2b905f1012aa0eac8db36b31ce01c3571f3
Author: Christian Brabandt <c...@256bit.org>
Date: Fri Jul 5 09:54:30 2024 +0200

patch 9.1.0531: resource leak in mch_get_random()

Problem: resource leak in mch_get_random() (after v9.1.0518)
Solution: close file descriptor after reading successfully
from /dev/urandom

Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/os_unix.c b/src/os_unix.c
index b7da55205..474d28801 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -7740,7 +7740,10 @@ mch_get_random(char_u *buf, int len)
if (fd == -1)
dev_urandom_state = FAIL;
else if (read(fd, buf, len) == len)
+ {
dev_urandom_state = OK;
+ close(fd);
+ }
else
{
dev_urandom_state = FAIL;
diff --git a/src/version.c b/src/version.c
index 159fe3b81..9cf60326a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 531,
/**/
530,
/**/
Reply all
Reply to author
Forward
0 new messages