Fix uncought fgets()

This commit is contained in:
realaltffour 2020-04-20 19:31:59 +03:00
parent f4a9705b93
commit 86befb46e8
No known key found for this signature in database
GPG Key ID: 7115CD2AC9A76A56
1 changed files with 4 additions and 1 deletions

View File

@ -26,6 +26,7 @@ int main()
xdg_cmd = popen("/bin/bash xdg-user-dir", "r");
if (!xdg_cmd) {
/* Default Download folder */
defaultDownloads:;
char *home_dir = getenv("HOME");
if (!home_dir) {
struct passwd *pw = getpwuid(getuid());
@ -40,7 +41,9 @@ int main()
strcat(downloads_dir, downloads_dir_default);
} else {
/* Read path from output of xdg */
fgets(downloads_dir, 4096, xdg_cmd);
if (!fgets(downloads_dir, 4096, xdg_cmd))
goto defaultDownloads;
fclose(xdg_cmd);
}