mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
66e0426907
commit
f64a4e9931
8
path.c
8
path.c
|
@ -55,6 +55,9 @@ char *get_path(const char *filename){
|
||||||
static char *config_dir = "/mplayer";
|
static char *config_dir = "/mplayer";
|
||||||
#else
|
#else
|
||||||
static char *config_dir = "/.mplayer";
|
static char *config_dir = "/.mplayer";
|
||||||
|
#endif
|
||||||
|
#if defined(__MINGW32__) || defined(__CYGWIN__)
|
||||||
|
char exedir[260];
|
||||||
#endif
|
#endif
|
||||||
int len;
|
int len;
|
||||||
#ifdef CONFIG_MACOSX_BUNDLE
|
#ifdef CONFIG_MACOSX_BUNDLE
|
||||||
|
@ -73,9 +76,8 @@ char *get_path(const char *filename){
|
||||||
/* Hack to get fonts etc. loaded outside of Cygwin environment. */
|
/* Hack to get fonts etc. loaded outside of Cygwin environment. */
|
||||||
{
|
{
|
||||||
int i,imax=0;
|
int i,imax=0;
|
||||||
char exedir[260];
|
len = (int)GetModuleFileNameA(NULL, exedir, 260);
|
||||||
GetModuleFileNameA(NULL, exedir, 260);
|
for (i=0; i < len; i++)
|
||||||
for (i=0; i< strlen(exedir); i++)
|
|
||||||
if (exedir[i] =='\\')
|
if (exedir[i] =='\\')
|
||||||
{exedir[i]='/'; imax=i;}
|
{exedir[i]='/'; imax=i;}
|
||||||
exedir[imax]='\0';
|
exedir[imax]='\0';
|
||||||
|
|
Loading…
Reference in New Issue