diff options
author | Martin Herkt <lachs0r@srsfckn.biz> | 2012-04-28 17:37:01 +0200 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2012-04-28 21:47:53 +0300 |
commit | f64a4e9931428de0f308f6ed0a0144edb8ce9619 (patch) | |
tree | 41b3e92d02621878d9665cd900e0ffd82331ce2c /path.c | |
parent | 66e0426907ae6c95959206d037cdd74c70198f1c (diff) | |
download | mpv-f64a4e9931428de0f308f6ed0a0144edb8ce9619.tar.bz2 mpv-f64a4e9931428de0f308f6ed0a0144edb8ce9619.tar.xz |
win32: get_path(): fix undefined behavior
MSWindows-specific code in get_path() declared a stack array
(exedir[]) in an inner scope, then kept a reference to the array
beyond the end of the that scope. Fix. This caused visible breakage
with GCC 4.7.
Diffstat (limited to 'path.c')
-rw-r--r-- | path.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -56,6 +56,9 @@ char *get_path(const char *filename){ #else static char *config_dir = "/.mplayer"; #endif +#if defined(__MINGW32__) || defined(__CYGWIN__) + char exedir[260]; +#endif int len; #ifdef CONFIG_MACOSX_BUNDLE struct stat dummy; @@ -73,9 +76,8 @@ char *get_path(const char *filename){ /* Hack to get fonts etc. loaded outside of Cygwin environment. */ { int i,imax=0; - char exedir[260]; - GetModuleFileNameA(NULL, exedir, 260); - for (i=0; i< strlen(exedir); i++) + len = (int)GetModuleFileNameA(NULL, exedir, 260); + for (i=0; i < len; i++) if (exedir[i] =='\\') {exedir[i]='/'; imax=i;} exedir[imax]='\0'; |