fix logfile_init

This commit is contained in:
Akos Horvath 2024-03-07 11:17:59 +01:00
parent 836241c014
commit cc0de7a72e

View File

@ -772,7 +772,8 @@ static void recursive_mkdir(char *path, mode_t mode)
void wm_logfile_init(const char *path) 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; if (access(path, F_OK) == 0) return;
@ -785,6 +786,7 @@ void wm_logfile_init(const char *path)
ret = close(ret); ret = close(ret);
if (ret < 0) CREATE_LOGFILE_ERROR(strerror(errno)); if (ret < 0) CREATE_LOGFILE_ERROR(strerror(errno));
free(dup);
return; return;
} }
@ -799,6 +801,8 @@ void wm_logfile_init(const char *path)
} else { } else {
CREATE_LOGFILE_ERROR(strerror(errno)); CREATE_LOGFILE_ERROR(strerror(errno));
} }
free(dup);
} }
/* UIntArray<LogEntry*> */ /* UIntArray<LogEntry*> */