Skip to content

Commit

Permalink
Fix segfault when no arg is given and no config file exists
Browse files Browse the repository at this point in the history
  • Loading branch information
emersion committed Oct 13, 2022
1 parent e103620 commit 24243ae
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,6 @@ static char *get_config_path(void) {

static int load_config(const char *config_path) {
FILE *f = fopen(config_path, "r");

if (!f) {
return -ENOENT;
}
Expand Down Expand Up @@ -1030,8 +1029,10 @@ int main(int argc, char *argv[]) {
config_path = get_config_path();
}

int config_load = load_config(config_path);

int config_load = -ENOENT;
if (config_path) {
config_load = load_config(config_path);
}
if (config_load == -ENOENT) {
swayidle_log(LOG_DEBUG, "No config file found.");
} else if (config_load == -EINVAL) {
Expand Down

0 comments on commit 24243ae

Please sign in to comment.