From: Suyeon Hwang Date: Mon, 31 Oct 2022 06:46:54 +0000 (+0900) Subject: Deallocate memory before setting new value X-Git-Tag: accepted/tizen/7.0/unified/20221107.172908~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=504e63517bc43b24b25df834b393814a2c26d0b4;p=platform%2Fcore%2Fuifw%2Fvoice-control.git 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 --- 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