Prevent double free 39/223439/1
authormk5004.lee <mk5004.lee@samsung.com>
Thu, 30 Jan 2020 01:02:14 +0000 (10:02 +0900)
committermk5004.lee <mk5004.lee@samsung.com>
Thu, 30 Jan 2020 01:02:14 +0000 (10:02 +0900)
Change-Id: I163864a86bd98a477165ba46c982fa22b1b880fe
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
lib/src/shortcut_db.c

index 65cd203..3d7649a 100644 (file)
@@ -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 */
        }