Skip to content

Commit

Permalink
log_cache: avoid double free by setting the log_cache pointer to NULL.
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Whelan <[email protected]>
  • Loading branch information
pwhelan authored and edsiper committed Jan 22, 2024
1 parent c111f0d commit 753591e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/flb_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/flb_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 753591e

Please sign in to comment.