Fix static analysis issues 82/284582/4
authorChanggyu Choi <changyu.choi@samsung.com>
Mon, 21 Nov 2022 08:14:52 +0000 (17:14 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Mon, 21 Nov 2022 10:16:06 +0000 (19:16 +0900)
Change-Id: I28acaeb2507b199fcbf1ac56c51120a0468c11b1
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
src/launchpad-process-pool/src/launchpad.c

index 058d75c..8ba6162 100644 (file)
@@ -968,6 +968,12 @@ static int __prepare_candidate_process(int type, int loader_id)
        _W("Candidate process. type: %d, loader_id: %d, pid: %d",
                        info->type, info->loader_id, info->pid);
        cpt = __find_slot(info->type, info->loader_id);
+       if (cpt == NULL) {
+               _E("Not found slot.");
+               __candidate_info_free(info);
+               return -1;
+       }
+
        cpt->last_exec_time = time(NULL);
        if (cpt->is_hydra) {
                cpt->hydra_pid = info->pid;
@@ -2648,10 +2654,11 @@ static bool __handle_launch_event(int fd, io_condition_e cond, void *data)
                }
        }
 
-       if (request->cmd < 0 || request->cmd > ARRAY_SIZE(__request_handlers) ||
-                       __request_handlers[request->cmd] == NULL) {
+       if (request->cmd < 0 || request->cmd >= ARRAY_SIZE(__request_handlers)
+                       || __request_handlers[request->cmd] == NULL) {
                _E("Unknown command: %d", request->cmd);
                __request_send_result(request, -EINVAL);
+               __request_destroy(request);
                return true;
        }