From 55590471706c8cd6e046b3b115aae018e9287584 Mon Sep 17 00:00:00 2001 From: Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com> Date: Fri, 17 Jan 2025 13:22:27 +0200 Subject: [PATCH] Fix coverity issues (#19422) Cleanup during shutdown if needed (address coverity warning) --- src/database/sqlite/sqlite_metadata.c | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/database/sqlite/sqlite_metadata.c b/src/database/sqlite/sqlite_metadata.c index 49e9d201664c2e..3bb54384b33a0e 100644 --- a/src/database/sqlite/sqlite_metadata.c +++ b/src/database/sqlite/sqlite_metadata.c @@ -2606,6 +2606,40 @@ static void metadata_event_loop(void *arg) completion_destroy(wc->scan_complete); freez(wc->scan_complete); } + + Word_t Index; + bool first; + + if (cl_cleanup_data) { + Index = 0; + first = true; + while ((PValue = JudyLFirstThenNext(cl_cleanup_data->JudyL, &Index, &first))) { + char *machine_guid = *PValue; + freez(machine_guid); + } + JudyLFreeArray(&cl_cleanup_data->JudyL, PJE0); + freez(cl_cleanup_data); + } + + if (pending_ae_list) { + (void)JudyLFreeArray(&pending_ae_list->JudyL, PJE0); + freez(pending_ae_list); + } + + if (pending_ctx_cleanup_list) { + Index = 0; + first = true; + while ((PValue = JudyLFirstThenNext(pending_ctx_cleanup_list->JudyL, &Index, &first))) { + if (!*PValue) + continue; + struct host_ctx_cleanup_s *ctx_cleanup = *PValue; + string_freez(ctx_cleanup->context); + freez(ctx_cleanup); + } + (void)JudyLFreeArray(&pending_ctx_cleanup_list->JudyL, PJE0); + freez(pending_ctx_cleanup_list); + } + metadata_free_cmd_queue(wc); return;