From 55066b995df15a588eb5502418d95c0e47080527 Mon Sep 17 00:00:00 2001 From: Scarcely There Date: Wed, 13 Mar 2024 00:22:49 -0500 Subject: [PATCH] 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. --- src/config/session.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/config/session.c b/src/config/session.c index e657a9ab..d2053068 100644 --- a/src/config/session.c +++ b/src/config/session.c @@ -118,14 +118,18 @@ read_environment_dir(const char *path_prefix) DIR *envdir = opendir(path); 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); wlr_log(WLR_INFO, "failed to read environment directory: %s", err_msg ? err_msg : "reason unknown"); } - goto env_dir_cleanup; + goto no_dir_cleanup; } struct dirent *dirent; @@ -142,8 +146,9 @@ read_environment_dir(const char *path_prefix) free(env_file_path); } -env_dir_cleanup: closedir(envdir); + +no_dir_cleanup: free(path); return success; }