X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=programs%2Fimagex-win32.c;h=ca34781680a88cde082fad4a17e83a5768817332;hb=ae49b84ee0f6f199b91029f03cf6798a0469091a;hp=19aa92cf0bb2fcb64fb7c3773b507789170cd03a;hpb=aaa78d43bcfd5edfd8116c2f3309b706c86ff6d1;p=wimlib diff --git a/programs/imagex-win32.c b/programs/imagex-win32.c index 19aa92cf..ca347816 100644 --- a/programs/imagex-win32.c +++ b/programs/imagex-win32.c @@ -14,7 +14,8 @@ #include #include -/* Replacement for glob() in Windows native builds. */ +/* Replacement for glob() in Windows native builds that operates on wide + * characters. */ int win32_wglob(const wchar_t *pattern, int flags, int (*errfunc)(const wchar_t *epath, int eerrno), @@ -80,7 +81,7 @@ win32_wglob(const wchar_t *pattern, int flags, size_t filename_len = wcslen(dat.cFileName); size_t len_needed = prefix_len + filename_len; - path = malloc(len_needed + sizeof(wchar_t)); + path = malloc((len_needed + 1) * sizeof(wchar_t)); if (!path) goto oom; @@ -191,6 +192,7 @@ win32_release_restore_privileges() win32_modify_restore_privileges(false); } +/* Convert a string from the "current Windows codepage" to UTF-16LE. */ wchar_t * win32_mbs_to_wcs(const char *mbs, size_t mbs_nbytes, size_t *num_wchars_ret) { @@ -242,6 +244,8 @@ is_path_separator(wchar_t c) return c == L'/' || c == L'\\'; } +/* basename() (modifying, trailing-slash stripping version) for wide-character + * strings. */ wchar_t * win32_wbasename(wchar_t *path) {