From cc0de7a72ee8aebedbf256341fb15430bcfecf28 Mon Sep 17 00:00:00 2001 From: Akos Horvath Date: Thu, 7 Mar 2024 11:17:59 +0100 Subject: [PATCH] fix logfile_init --- src/util.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/util.c b/src/util.c index d6133e6..79afad6 100644 --- a/src/util.c +++ b/src/util.c @@ -772,7 +772,8 @@ static void recursive_mkdir(char *path, mode_t mode) void wm_logfile_init(const char *path) { - char *log_file_dir = dirname((char*)path); + char *dup = strdup(path); + char *log_file_dir = dirname(dup); if (access(path, F_OK) == 0) return; @@ -785,6 +786,7 @@ void wm_logfile_init(const char *path) ret = close(ret); if (ret < 0) CREATE_LOGFILE_ERROR(strerror(errno)); + free(dup); return; } @@ -799,6 +801,8 @@ void wm_logfile_init(const char *path) } else { CREATE_LOGFILE_ERROR(strerror(errno)); } + + free(dup); } /* UIntArray */