Commit 994394bc authored by François Grisez's avatar François Grisez

Fix potential unreleased mutex

parent e449dc9f
...@@ -714,7 +714,7 @@ static void _close_log_collection_file(bctbx_file_log_handler_t *filehandler) { ...@@ -714,7 +714,7 @@ static void _close_log_collection_file(bctbx_file_log_handler_t *filehandler) {
void bctbx_logv_file(void* user_info, const char *domain, BctbxLogLevel lev, const char *fmt, va_list args){ void bctbx_logv_file(void* user_info, const char *domain, BctbxLogLevel lev, const char *fmt, va_list args){
const char *lname="undef"; const char *lname="undef";
char *msg; char *msg = NULL;
struct timeval tp; struct timeval tp;
struct tm *lt; struct tm *lt;
#ifndef _WIN32 #ifndef _WIN32
...@@ -727,9 +727,7 @@ void bctbx_logv_file(void* user_info, const char *domain, BctbxLogLevel lev, con ...@@ -727,9 +727,7 @@ void bctbx_logv_file(void* user_info, const char *domain, BctbxLogLevel lev, con
bctbx_logger_t *logger = bctbx_get_logger(); bctbx_logger_t *logger = bctbx_get_logger();
bctbx_mutex_lock(&logger->log_mutex); bctbx_mutex_lock(&logger->log_mutex);
if (filehandler != NULL){ f = filehandler ? filehandler->file : stdout;
f = filehandler->file;
}else f = stdout;
bctbx_gettimeofday(&tp,NULL); bctbx_gettimeofday(&tp,NULL);
tt = (time_t)tp.tv_sec; tt = (time_t)tp.tv_sec;
...@@ -739,9 +737,8 @@ void bctbx_logv_file(void* user_info, const char *domain, BctbxLogLevel lev, con ...@@ -739,9 +737,8 @@ void bctbx_logv_file(void* user_info, const char *domain, BctbxLogLevel lev, con
lt = localtime_r(&tt,&tmbuf); lt = localtime_r(&tt,&tmbuf);
#endif #endif
if(!f) { if(!f) goto end;
return;
}
switch(lev){ switch(lev){
case BCTBX_LOG_DEBUG: case BCTBX_LOG_DEBUG:
lname = "debug"; lname = "debug";
...@@ -789,9 +786,10 @@ void bctbx_logv_file(void* user_info, const char *domain, BctbxLogLevel lev, con ...@@ -789,9 +786,10 @@ void bctbx_logv_file(void* user_info, const char *domain, BctbxLogLevel lev, con
_open_log_collection_file(filehandler); _open_log_collection_file(filehandler);
} }
} }
bctbx_mutex_unlock(&logger->log_mutex);
bctbx_free(msg); end:
bctbx_mutex_unlock(&logger->log_mutex);
if (msg) bctbx_free(msg);
} }
void bctbx_logv_file_destroy(bctbx_log_handler_t* handler) { void bctbx_logv_file_destroy(bctbx_log_handler_t* handler) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment