Fix static analysis issue 11/115111/1
authorJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 16 Feb 2017 08:18:19 +0000 (17:18 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 16 Feb 2017 09:46:19 +0000 (18:46 +0900)
Change-Id: Id0894b1f2bb0ee9bf33c6c8737a5c0fa614c83a7
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/pkgmgrinfo_pkginfo.c

index f838d35..64f8564 100644 (file)
@@ -445,9 +445,8 @@ static int _pkginfo_get_packages(uid_t uid, const char *locale,
                info = calloc(1, sizeof(package_x));
                if (info == NULL) {
                        LOGE("out of memory");
-                       sqlite3_finalize(stmt);
-                       sqlite3_close_v2(db);
-                       return PMINFO_R_ERROR;
+                       ret = PMINFO_R_ERROR;
+                       goto catch;
                }
                idx = 0;
                _save_column_str(stmt, idx++, &info->package);
@@ -488,10 +487,8 @@ static int _pkginfo_get_packages(uid_t uid, const char *locale,
                        /* TODO : author should be retrieved at package_localized_info */
                        author = calloc(1, sizeof(author_x));
                        if (author == NULL) {
-                               pkgmgrinfo_basic_free_package(info);
-                               sqlite3_finalize(stmt);
-                               sqlite3_close_v2(db);
-                               return PMINFO_R_ERROR;
+                               ret = PMINFO_R_ERROR;
+                               goto catch;
                        }
                        _save_column_str(stmt, idx++, &author->text);
                        _save_column_str(stmt, idx++, &author->email);
@@ -504,10 +501,8 @@ static int _pkginfo_get_packages(uid_t uid, const char *locale,
                        _save_column_str(stmt, idx++, &tmp_record);
 
                        if (_add_label_info_into_list(locale, tmp_record, &info->label)) {
-                               pkgmgrinfo_basic_free_package(info);
-                               sqlite3_finalize(stmt);
-                               sqlite3_close_v2(db);
-                               return PMINFO_R_ERROR;
+                               ret = PMINFO_R_ERROR;
+                               goto catch;
                        }
                }
 
@@ -515,10 +510,8 @@ static int _pkginfo_get_packages(uid_t uid, const char *locale,
                        tmp_record = NULL;
                        _save_column_str(stmt, idx++, &tmp_record);
                        if (_add_icon_info_into_list(locale, tmp_record, &info->icon)) {
-                               pkgmgrinfo_basic_free_package(info);
-                               sqlite3_finalize(stmt);
-                               sqlite3_close_v2(db);
-                               return PMINFO_R_ERROR;
+                               ret = PMINFO_R_ERROR;
+                               goto catch;
                        }
                }
 
@@ -527,20 +520,16 @@ static int _pkginfo_get_packages(uid_t uid, const char *locale,
                        _save_column_str(stmt, idx++, &tmp_record);
                        if (_pkginfo_add_description_info_into_list(locale, tmp_record,
                                        &info->description)) {
-                               pkgmgrinfo_basic_free_package(info);
-                               sqlite3_finalize(stmt);
-                               sqlite3_close_v2(db);
-                               return PMINFO_R_ERROR;
+                               ret = PMINFO_R_ERROR;
+                               goto catch;
                        }
                }
 
                if (flag & PMINFO_PKGINFO_GET_PRIVILEGE) {
                        if (_pkginfo_get_privilege(db, info->package,
                                                &info->privileges)) {
-                               pkgmgrinfo_basic_free_package(info);
-                               sqlite3_finalize(stmt);
-                               sqlite3_close_v2(db);
-                               return PMINFO_R_ERROR;
+                               ret = PMINFO_R_ERROR;
+                               goto catch;
                        }
                }
 
@@ -605,6 +594,7 @@ static int _pkginfo_get_filtered_foreach_pkginfo(uid_t uid,
                ret = pkgmgrinfo_pkginfo_filter_create((void *)&tmp_filter);
                if (ret != PMINFO_R_OK) {
                        _LOGE("Failed to create filter");
+                       g_hash_table_destroy(list);
                        return PMINFO_R_ERROR;
                }
        }
@@ -1822,6 +1812,7 @@ API int pkgmgrinfo_pkginfo_usr_filter_count(pkgmgrinfo_pkginfo_filter_h handle,
                                PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, false);
                if (ret != PMINFO_R_OK) {
                        free(locale);
+                       g_hash_table_destroy(list);
                        return PMINFO_R_ERROR;
                }
        }