summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-09-18 17:02:31 +0200
committerwm4 <wm4@nowhere>2013-09-20 21:20:58 +0200
commitbb2238516b7f9709dd7ba650b1cdaf551a4fb78a (patch)
tree27026671c36fc975c16cab1256ffa8a09a8b59f1
parentab816f1ab19bbe376c9aac7ec8920098ecea700d (diff)
downloadmpv-bb2238516b7f9709dd7ba650b1cdaf551a4fb78a.tar.bz2
mpv-bb2238516b7f9709dd7ba650b1cdaf551a4fb78a.tar.xz
path: fix undefined behavior
The homepath variable was static, and its value was set to a stack buffer. This means a second invocation of the function would trigger undefined behavior. Moreover the stack buffer always went out of scope before homepath was used.
-rw-r--r--mpvcore/path.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/mpvcore/path.c b/mpvcore/path.c
index 68051b701d..4deb7ef281 100644
--- a/mpvcore/path.c
+++ b/mpvcore/path.c
@@ -78,12 +78,12 @@ char *mp_find_config_file(const char *filename)
char *mp_find_user_config_file(const char *filename)
{
char *homedir = NULL, *buff = NULL;
- static char *homepath = NULL;
+ char *homepath = NULL;
#ifdef __MINGW32__
char *config_dir = "mpv";
+ char buf[MAX_PATH];
if (homepath == NULL) {
- char buf[MAX_PATH];
if (SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE, NULL,
SHGFP_TYPE_CURRENT, buf) == S_OK) {