From: Yunhee Seo Date: Thu, 23 Nov 2023 02:14:11 +0000 (+0900) Subject: sound: Resolve malloc/free mismatch issue X-Git-Tag: accepted/tizen/7.0/unified/20231206.171443~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e6ae3029e4d00da710a294ff93fcedb74d7753bd;p=platform%2Fcore%2Fsystem%2Flibsvi.git sound: Resolve malloc/free mismatch issue There was a part where free was omitted in the code. Change-Id: I0b20af7ca585eb5c931a42d9434cc81063889cef Signed-off-by: Yunhee Seo --- diff --git a/src/sound-theme-manager.c b/src/sound-theme-manager.c index 3901f66..7b60a56 100644 --- a/src/sound-theme-manager.c +++ b/src/sound-theme-manager.c @@ -56,8 +56,10 @@ bool sound_thememan_is_sound_theme_id_exist(unsigned int sound_theme_id) gint *hash_key = g_new(gint, 1); *hash_key = sound_theme_id; - if (!is_g_sound_theme_list_initialized()) + if (!is_g_sound_theme_list_initialized()) { + g_free(hash_key); return false; + } if (!g_hash_table_lookup(g_sound_theme_list, hash_key)) { g_free(hash_key); @@ -92,8 +94,10 @@ int sound_thememan_get_sound_theme_info(unsigned int sound_theme_id, void *sound gint *hash_key = g_new(gint, 1); struct feedback_config_info* sound_theme_info; - if (!is_g_sound_theme_list_initialized()) + if (!is_g_sound_theme_list_initialized()) { + g_free(hash_key); return -EPERM; + } *hash_key = sound_theme_id; sound_theme_info = (struct feedback_config_info*)g_hash_table_lookup(g_sound_theme_list, hash_key); @@ -109,7 +113,7 @@ int sound_thememan_get_sound_theme_info(unsigned int sound_theme_id, void *sound int sound_thememan_add_sound_theme(unsigned int sound_theme_id, const char* conf_file_path) { struct feedback_config_info *sound_info = NULL; - gint *hash_key = g_new(gint, 1); + gint *hash_key = NULL; int ret = 0; if (!is_g_sound_theme_list_initialized()) @@ -125,9 +129,12 @@ int sound_thememan_add_sound_theme(unsigned int sound_theme_id, const char* conf ret = feedback_load_config(conf_file_path, sound_info); if (ret < 0) { _E("Failed to load config file %s", conf_file_path); + feedback_free_config(sound_info); + free(sound_info); return ret; } + hash_key = g_new(gint, 1); *hash_key = sound_theme_id; g_hash_table_insert(g_sound_theme_list, hash_key, (gpointer)sound_info); return 0;