From f44db5a712851295e8e7d7ca9ce29df42055578c Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Tue, 23 May 2023 17:42:08 +0000 Subject: [PATCH] Properly initialize and destroy logging mutex in LogConfigCreate() and LogConfigFree(), respectively. --- src/Log.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Log.c b/src/Log.c index f24ee23..1288bb7 100644 --- a/src/Log.c +++ b/src/Log.c @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -60,6 +61,7 @@ LogConfigCreate(void) } memset(config, 0, sizeof(LogConfig)); + pthread_mutex_init(&config->lock, NULL); LogConfigLevelSet(config, LOG_INFO); LogConfigIndentSet(config, 0); @@ -122,6 +124,8 @@ LogConfigFree(LogConfig * config) return; } + pthread_mutex_destroy(&config->lock); + Free(config->tsFmt); Free(config); if (config == globalConfig) @@ -205,7 +209,7 @@ LogConfigTimeStampFormatSet(LogConfig * config, char *tsFmt) { if (config) { - config->tsFmt = tsFmt; + config->tsFmt = StrDuplicate(tsFmt); } }