From 753591eb8e3e066fec751f970108afee2cf8a4bf Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Thu, 18 Jan 2024 20:24:35 -0300 Subject: [PATCH] log_cache: avoid double free by setting the log_cache pointer to NULL. Signed-off-by: Phillip Whelan --- src/flb_log.c | 1 + src/flb_worker.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/flb_log.c b/src/flb_log.c index 89c4715f12f..f9c7bfbc15d 100644 --- a/src/flb_log.c +++ b/src/flb_log.c @@ -692,6 +692,7 @@ int flb_log_destroy(struct flb_log *log, struct flb_config *config) flb_pipe_destroy(log->ch_mng); if (log->worker->log_cache) { flb_log_cache_destroy(log->worker->log_cache); + log->worker->log_cache = NULL; } flb_log_worker_destroy(log->worker); flb_free(log->worker); diff --git a/src/flb_worker.c b/src/flb_worker.c index 43bdad7b3cf..87bc006433d 100644 --- a/src/flb_worker.c +++ b/src/flb_worker.c @@ -142,6 +142,10 @@ void flb_worker_destroy(struct flb_worker *worker) return; } + if (worker->log_cache) { + flb_log_cache_destroy(worker->log_cache); + worker->log_cache = NULL; + } flb_log_worker_destroy(worker); mk_list_del(&worker->_head);