From 2861c3105e1605c0a0b037558b0ccf54c9780678 Mon Sep 17 00:00:00 2001
From: liuxu <liuxu156@huawei.com>
Date: Tue, 11 Feb 2025 11:08:31 +0800
Subject: [PATCH 191/198] bugfix:dereference null pointer

Signed-off-by: liuxu <liuxu156@huawei.com>
---
 src/daemon/modules/container/container_gc/containers_gc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/daemon/modules/container/container_gc/containers_gc.c b/src/daemon/modules/container/container_gc/containers_gc.c
index 3f2473d5..5dd299dc 100644
--- a/src/daemon/modules/container/container_gc/containers_gc.c
+++ b/src/daemon/modules/container/container_gc/containers_gc.c
@@ -461,15 +461,16 @@ static void gc_container_process(struct linked_list *it)
     unsigned long long start_time = 0;
     char *runtime = NULL;
     char *id = NULL;
-    container_garbage_config_gc_containers_element *gc_cont = NULL;
+    container_garbage_config_gc_containers_element *gc_cont = (container_garbage_config_gc_containers_element *)it->elem;
     rt_detect_process_params_t detect_params = {
         .pid = gc_cont->pid,
         .start_time = gc_cont->start_time,
     };
 
-    gc_cont = (container_garbage_config_gc_containers_element *)it->elem;
     id = gc_cont->id;
     runtime = gc_cont->runtime;
+    pid = gc_cont->pid;
+    start_time = gc_cont->start_time;
 
     if (runtime_detect_process(id, runtime, &detect_params) < 0) {
         ret = clean_container_resource(id, runtime, pid);
-- 
2.34.1

