mirror of
https://github.com/labwc/labwc.git
synced 2026-04-14 08:21:58 -04:00
session: Don't close a null dir in read_environment_dir
There was a cleanup path in read_environment_dir that called closedir() on a null DIR* from opendir(). This removes closedir() from that path. We also log when environment.d doesn't exist, as opposed to only logging when another error occurred.
This commit is contained in:
parent
5cb3583108
commit
55066b995d
1 changed files with 8 additions and 3 deletions
|
|
@ -118,14 +118,18 @@ read_environment_dir(const char *path_prefix)
|
||||||
DIR *envdir = opendir(path);
|
DIR *envdir = opendir(path);
|
||||||
|
|
||||||
if (!envdir) {
|
if (!envdir) {
|
||||||
if (errno != ENOENT) {
|
if (errno == ENOENT) {
|
||||||
|
wlr_log(WLR_INFO,
|
||||||
|
"no %s.d directory found",
|
||||||
|
path_prefix);
|
||||||
|
} else {
|
||||||
const char *err_msg = strerror(errno);
|
const char *err_msg = strerror(errno);
|
||||||
wlr_log(WLR_INFO,
|
wlr_log(WLR_INFO,
|
||||||
"failed to read environment directory: %s",
|
"failed to read environment directory: %s",
|
||||||
err_msg ? err_msg : "reason unknown");
|
err_msg ? err_msg : "reason unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
goto env_dir_cleanup;
|
goto no_dir_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct dirent *dirent;
|
struct dirent *dirent;
|
||||||
|
|
@ -142,8 +146,9 @@ read_environment_dir(const char *path_prefix)
|
||||||
free(env_file_path);
|
free(env_file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
env_dir_cleanup:
|
|
||||||
closedir(envdir);
|
closedir(envdir);
|
||||||
|
|
||||||
|
no_dir_cleanup:
|
||||||
free(path);
|
free(path);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue