diff options
author | mk5004.lee <mk5004.lee@samsung.com> | 2020-01-30 10:02:14 +0900 |
---|---|---|
committer | mk5004.lee <mk5004.lee@samsung.com> | 2020-01-30 10:02:14 +0900 |
commit | 86123ce3d6f0746bed1ebb1561958c40af4bbbe2 (patch) | |
tree | 59831efaa0d9fb69f6c8e6cbb15b9b03aa5854ad | |
parent | dd93f992543e802ca4ead599793e609228b03585 (diff) | |
download | shortcut-86123ce3d6f0746bed1ebb1561958c40af4bbbe2.tar.gz shortcut-86123ce3d6f0746bed1ebb1561958c40af4bbbe2.tar.bz2 shortcut-86123ce3d6f0746bed1ebb1561958c40af4bbbe2.zip |
Prevent double free
Change-Id: I163864a86bd98a477165ba46c982fa22b1b880fe
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
-rw-r--r-- | lib/src/shortcut_db.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/src/shortcut_db.c b/lib/src/shortcut_db.c index 65cd203..3d7649a 100644 --- a/lib/src/shortcut_db.c +++ b/lib/src/shortcut_db.c @@ -239,8 +239,10 @@ static inline int _get_i18n_name(sqlite3 *handle, const char *lang, int id, char if (!*icon) { SHORTCUT_ERR("strdup: %d\n", errno); ret = -ENOMEM; - if (name && *name) + if (name && *name) { free(*name); + *name = NULL; + } goto out; } @@ -413,11 +415,15 @@ EAPI int shortcut_db_get_list(const char *package_name, GList **shortcut_list) shortcut->extra_data = strdup((char *)extra_data); *shortcut_list = g_list_append(*shortcut_list, shortcut); - free(i18n_name); - i18n_name = NULL; + if (i18n_name) { + free(i18n_name); + i18n_name = NULL; + } - free(i18n_icon); - i18n_icon = NULL; + if (i18n_icon) { + free(i18n_icon); + i18n_icon = NULL; + } /* LCOV_EXCL_STOP */ } |