From 1ec5765f3f7fcfcd852bbcd24fc5b68a67234b0a Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Mon, 21 Nov 2022 15:52:23 -0300 Subject: [PATCH] VISO: Fix file descriptor leak on directory traversal --- src/cdrom/cdrom_image_viso.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cdrom/cdrom_image_viso.c b/src/cdrom/cdrom_image_viso.c index 86285ee4b..46df986c0 100644 --- a/src/cdrom/cdrom_image_viso.c +++ b/src/cdrom/cdrom_image_viso.c @@ -859,7 +859,7 @@ viso_init(const char *dirname, int *error) /* Iterate through this directory's children again, making the entries. */ if (dirp) { - rewinddir(dirp); + rewinddir(dirp); while ((readdir_entry = readdir(dirp))) { /* Ignore . and .. pseudo-directories. */ if ((readdir_entry->d_name[0] == '.') && ((readdir_entry->d_name[1] == '\0') || (*((uint16_t *) &readdir_entry->d_name[1]) == '.'))) @@ -931,6 +931,7 @@ viso_init(const char *dirname, int *error) cdrom_image_viso_log("[%08X] %s => [%-12s] %s\n", entry, dir->path, entry->name_short, entry->basename); } + closedir(dirp); } else { cdrom_image_viso_log("VISO: Failed to enumerate [%s], will be empty\n", dir->path); }