mirror of
https://github.com/mpv-player/mpv
synced 2025-04-11 04:01:31 +00:00
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.
This commit is contained in:
parent
bb4ea8bb3e
commit
b97d10a839
@ -78,12 +78,12 @@ char *mp_find_config_file(const char *filename)
|
|||||||
char *mp_find_user_config_file(const char *filename)
|
char *mp_find_user_config_file(const char *filename)
|
||||||
{
|
{
|
||||||
char *homedir = NULL, *buff = NULL;
|
char *homedir = NULL, *buff = NULL;
|
||||||
static char *homepath = NULL;
|
char *homepath = NULL;
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
char *config_dir = "mpv";
|
char *config_dir = "mpv";
|
||||||
|
char buf[MAX_PATH];
|
||||||
|
|
||||||
if (homepath == NULL) {
|
if (homepath == NULL) {
|
||||||
char buf[MAX_PATH];
|
|
||||||
if (SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE, NULL,
|
if (SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE, NULL,
|
||||||
SHGFP_TYPE_CURRENT, buf) == S_OK) {
|
SHGFP_TYPE_CURRENT, buf) == S_OK) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user