commit 92634bf3479e2af9abe425dd056015477865adda
Author: Noseey <omega_1986@hotmail.com>
AuthorDate: Fri Nov 7 14:50:24 2025 +0100
Commit: GitHub <noreply@github.com>
CommitDate: Fri Nov 7 14:50:24 2025 +0100
win_opendir: ensure no trailing backslash before __internal_opendir (#1770)
* win_opendir: add backslash to directory path if not present
* win_opendir: ensure no trailing backslash before __internal_opendir
.. easier solution than adding the backslash if not present.
---
win32/win_opendir.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/win32/win_opendir.c b/win32/win_opendir.c
index 59a5979b..3ec6227c 100644
--- a/win32/win_opendir.c
+++ b/win32/win_opendir.c
@@ -330,6 +330,13 @@ DIR *opendir(const char *name)
free(wname);
return NULL;
}
+ /* Ensure path has no trailing backslash before __internal_opendir. */
+ /* Mind that size includes NULL, thus -2 for last character. */
+ if (wname[size+4-2] == L'\\')
+ {
+ wname[size+4-2] = 0;
+ size--;
+ }
dirp = __internal_opendir(wname, size + 4);
free(wname);
return dirp;