Commit ce32a19 for zlib
commit ce32a19c5fe71cc38031b81b79fc141693a4c718
Author: Mark Adler <git@madler.net>
Date: Sun Oct 25 20:07:37 2026 -0700
Fix gzopen_w() for paths not representable in the locale.
diff --git a/gzlib.c b/gzlib.c
index 29cb25a..d849196 100644
--- a/gzlib.c
+++ b/gzlib.c
@@ -198,8 +198,11 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
/* save the path name for error messages */
#ifdef WIDECHAR
- if (fd == -2)
+ if (fd == -2) {
len = wcstombs(NULL, path, 0);
+ if (len == (z_size_t)-1)
+ len = 0; /* not representable in the current locale */
+ }
else
#endif
len = strlen((const char *)path);
@@ -210,9 +213,7 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
}
#ifdef WIDECHAR
if (fd == -2) {
- if (len)
- wcstombs(state->path, path, len + 1);
- else
+ if (len == 0 || wcstombs(state->path, path, len + 1) != len)
*(state->path) = 0;
}
else