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 */