From 9565675488c51133e85627e5e610bf631eca6289 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sat, 23 Dec 2023 18:46:54 +0100 Subject: various: use correct PATH_MAX for win32 In commit c09245cdf2491211f3e0bfe47f28cc0e0a2e05c8 long-path support was enabled for mpv without actually making sure that there was no code left that used the old limit (260 Unicode chars) for buffer sizes. This commit fixes all but one case. --- osdep/path-win.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'osdep/path-win.c') diff --git a/osdep/path-win.c b/osdep/path-win.c index bddf5a5e19..3b104cac03 100644 --- a/osdep/path-win.c +++ b/osdep/path-win.c @@ -24,17 +24,15 @@ #include "osdep/path.h" #include "osdep/threads.h" -// Warning: do not use PATH_MAX. Cygwin messed it up. - static mp_once path_init_once = MP_STATIC_ONCE_INITIALIZER; static char *portable_path; static char *mp_get_win_exe_dir(void *talloc_ctx) { - wchar_t w_exedir[MAX_PATH + 1] = {0}; + wchar_t *w_exedir = talloc_array(NULL, wchar_t, MP_PATH_MAX); - int len = (int)GetModuleFileNameW(NULL, w_exedir, MAX_PATH); + int len = (int)GetModuleFileNameW(NULL, w_exedir, MP_PATH_MAX); int imax = 0; for (int i = 0; i < len; i++) { if (w_exedir[i] == '\\') { @@ -42,10 +40,11 @@ static char *mp_get_win_exe_dir(void *talloc_ctx) imax = i; } } - w_exedir[imax] = '\0'; - return mp_to_utf8(talloc_ctx, w_exedir); + char *ret = mp_to_utf8(talloc_ctx, w_exedir); + talloc_free(w_exedir); + return ret; } static char *mp_get_win_exe_subdir(void *ta_ctx, const char *name) -- cgit v1.2.3