path-unix: check fopen value, and also call fclose
This commit is contained in:
1 parent
a3350e2fbb
commit
0035bb7cbd
1 file changed
+4
@@ -79,6 +79,8 @@ static void path_init(void)
|
||||
if (mp_path_exists(xdg_user_dirs)) {
|
||||
char line[4096];
|
||||
FILE *user_dirs = fopen(xdg_user_dirs, "r");
|
||||
if (!user_dirs)
|
||||
goto skip_user_dirs;
|
||||
while (fgets(line, sizeof(line), user_dirs)) {
|
||||
bstr data = bstr0(line);
|
||||
if (bstr_eatstart0(&data, "XDG_DESKTOP_DIR=")) {
|
||||
@@ -94,8 +96,10 @@ static void path_init(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(user_dirs);
|
||||
}
|
||||
|
||||
skip_user_dirs:
|
||||
if (!mpv_desktop[0])
|
||||
err = err || MKPATH(mpv_desktop, "%s/%s", home, "Desktop");
|
||||
|
||||
|
||||
Reference in new issue
Block a user