summaryrefslogtreecommitdiffstats
path: root/osdep/path-win.c
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2023-12-23 18:46:54 +0100
committersfan5 <sfan5@live.de>2023-12-27 22:55:56 +0100
commit9565675488c51133e85627e5e610bf631eca6289 (patch)
tree8b8df1dab6b396097916d5115e8047241a0be910 /osdep/path-win.c
parentf57ec94d9f176184414ad8ef916a0b657c1b22ec (diff)
downloadmpv-9565675488c51133e85627e5e610bf631eca6289.tar.bz2
mpv-9565675488c51133e85627e5e610bf631eca6289.tar.xz
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.
Diffstat (limited to 'osdep/path-win.c')
-rw-r--r--osdep/path-win.c11
1 files changed, 5 insertions, 6 deletions
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)