From a5ea5f157aa54e6da60b7182b88168b4566d3e57 Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Sat, 13 Jul 2024 12:30:33 +0200 Subject: [PATCH] dlt-user: fix address sanitzer issue --- src/lib/dlt_user.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index 6591b93c4..3ce186d1e 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -99,11 +99,12 @@ enum InitState { static DltUser dlt_user; static _Atomic enum InitState dlt_user_init_state = INIT_UNITIALIZED; -#define DLT_USER_INITALIZED (dlt_user_init_state == INIT_DONE) static _Atomic int dlt_user_freeing = 0; static bool dlt_user_file_reach_max = false; +#define DLT_USER_INITALIZED ((dlt_user_init_state == INIT_DONE) && !dlt_user_freeing) + #ifdef DLT_LIB_USE_FIFO_IPC static char dlt_user_dir[DLT_PATH_MAX]; static char dlt_daemon_fifo[DLT_PATH_MAX]; @@ -457,7 +458,9 @@ DltReturnValue dlt_init(void) { /* process is exiting. Do not allocate new resources. */ if (dlt_user_freeing != 0) { +#ifndef DLT_UNIT_TESTS dlt_vlog(LOG_INFO, "%s logging disabled, process is exiting\n", __func__); +#endif /* return negative value, to stop the current log */ return DLT_RETURN_LOGGING_DISABLED; } @@ -4887,6 +4890,10 @@ void dlt_user_log_reattach_to_daemon(void) DltContext handle; DltContextData log_new; + if (!DLT_USER_INITALIZED) { + return; + } + if (dlt_user.dlt_log_handle < 0) { dlt_user.dlt_log_handle = DLT_FD_INIT;