From 504e63517bc43b24b25df834b393814a2c26d0b4 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Mon, 31 Oct 2022 15:46:54 +0900 Subject: [PATCH] Deallocate memory before setting new value - Issue: Memory leak can be possible if vc_cmd_db module sets the new value in vc_cmd_s structure. - Solution: The possibility of the issue is because the module did not check the preivous value of the member. Thus, this patch adds code for checking the member of the structure. If there is already value set, the module will release the old value and then set new value. Change-Id: I2d2676d08a4cacb75c32983c1a49eced28371b65 Signed-off-by: Suyeon Hwang --- common/vc_cmd_db.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index e41b291..154a4fa 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -2185,6 +2185,8 @@ static int __vc_db_insert_command(sqlite3* db_handle, int pid, vc_cmd_type_e typ tmp_cmd->command = NULL; } tmp_cmd->command = strdup(temp_command); + + free(tmp_cmd->fixed); if (NULL != fixed_cmd) tmp_cmd->fixed = strdup(fixed_cmd); else -- 2.7.4