[Non-ACR] memory leak fixes 67/259067/2 accepted/tizen_6.5_unified accepted/tizen_7.0_unified accepted/tizen_7.0_unified_hotfix accepted/tizen_8.0_unified accepted/tizen_unified tizen_6.5 tizen_7.0 tizen_7.0_hotfix tizen_8.0 accepted/tizen/6.5/unified/20211028.093933 accepted/tizen/7.0/unified/20221110.063806 accepted/tizen/7.0/unified/hotfix/20221116.104534 accepted/tizen/8.0/unified/20231005.092549 accepted/tizen/unified/20210611.145006 submit/tizen/20210610.065903 submit/tizen_6.5/20211028.161601 tizen_6.5.m2_release tizen_7.0_m2_release tizen_8.0_m2_release
authorAbhishek Vijay <abhishek.v@samsung.com>
Mon, 31 May 2021 12:55:20 +0000 (18:25 +0530)
committerAbhishek Vijay <abhishek.v@samsung.com>
Mon, 31 May 2021 12:58:35 +0000 (18:28 +0530)
Change-Id: Icfa764547900dd479be66b30d001f2e82ce6691c
Signed-off-by: Abhishek Vijay <abhishek.v@samsung.com>
common/src/account_db_helper.c

index c05fd42..a89a628 100644 (file)
@@ -1016,10 +1016,29 @@ int _account_get_represented_appid_from_db(sqlite3 *account_user_db, sqlite3 *ac
        /* Get app id family which is stored in account database */
        _account_get_appid_from_db(&ahandle, &phandle, &package_id, appid, uid, &appid_list);
 
-       ACCOUNT_RETURN_VAL((ahandle != NULL), {}, _ACCOUNT_ERROR_NO_DATA, ("appinfo handle is NULL"));
-       ACCOUNT_RETURN_VAL((phandle != NULL), {}, _ACCOUNT_ERROR_NO_DATA, ("pkginfo handle is NULL"));
-       ACCOUNT_RETURN_VAL((package_id != NULL), {}, _ACCOUNT_ERROR_NO_DATA, ("package_id is NULL"));
-       ACCOUNT_RETURN_VAL((appid_list != NULL), {}, _ACCOUNT_ERROR_NO_DATA, ("appid_list is NULL"));
+       ACCOUNT_RETURN_VAL((ahandle != NULL), {
+                                               if (phandle) pkgmgrinfo_pkginfo_destroy_pkginfo(phandle);
+                                               if (package_id) free(package_id);
+                                               if (appid_list) g_slist_free(appid_list);
+                                       }, _ACCOUNT_ERROR_NO_DATA, ("appinfo handle is NULL"));
+
+       ACCOUNT_RETURN_VAL((phandle != NULL), {
+                                               if (ahandle) pkgmgrinfo_appinfo_destroy_appinfo(ahandle);
+                                               if (package_id) free(package_id);
+                                               if (appid_list) g_slist_free(appid_list);
+                                       }, _ACCOUNT_ERROR_NO_DATA, ("pkginfo handle is NULL"));
+
+       ACCOUNT_RETURN_VAL((package_id != NULL), {
+                                               if (phandle) pkgmgrinfo_pkginfo_destroy_pkginfo(phandle);
+                                               if (ahandle) pkgmgrinfo_appinfo_destroy_appinfo(ahandle);
+                                               if (appid_list) g_slist_free(appid_list);
+                                       }, _ACCOUNT_ERROR_NO_DATA, ("package_id is NULL"));
+
+       ACCOUNT_RETURN_VAL((appid_list != NULL), {
+                                               if (phandle) pkgmgrinfo_pkginfo_destroy_pkginfo(phandle);
+                                               if (ahandle) pkgmgrinfo_appinfo_destroy_appinfo(ahandle);
+                                               if (package_id) free(package_id);
+                                       }, _ACCOUNT_ERROR_NO_DATA, ("appid_list is NULL"));
 
        /* Compare current app id with the stored app id family */
        for (iter = appid_list; iter != NULL; iter = g_slist_next(iter)) {
@@ -1077,10 +1096,29 @@ int _account_check_appid_group_with_package_name(const char *appid, char *packag
        /* Get app id family which is stored in account database */
        _account_get_appid_from_db(&ahandle, &phandle, &package_id, appid, uid, &appid_list);
 
-       ACCOUNT_RETURN_VAL((ahandle != NULL), {}, _ACCOUNT_ERROR_NO_DATA, ("appinfo handle is NULL"));
-       ACCOUNT_RETURN_VAL((phandle != NULL), {}, _ACCOUNT_ERROR_NO_DATA, ("pkginfo handle is NULL"));
-       ACCOUNT_RETURN_VAL((package_id != NULL), {}, _ACCOUNT_ERROR_NO_DATA, ("package_id is NULL"));
-       ACCOUNT_RETURN_VAL((appid_list != NULL), {}, _ACCOUNT_ERROR_NO_DATA, ("appid_list is NULL"));
+       ACCOUNT_RETURN_VAL((ahandle != NULL), {
+                                               if (phandle) pkgmgrinfo_pkginfo_destroy_pkginfo(phandle);
+                                               if (package_id) free(package_id);
+                                               if (appid_list) g_slist_free(appid_list);
+                                       }, _ACCOUNT_ERROR_NO_DATA, ("appinfo handle is NULL"));
+
+       ACCOUNT_RETURN_VAL((phandle != NULL), {
+                                               if (ahandle) pkgmgrinfo_appinfo_destroy_appinfo(ahandle);
+                                               if (package_id) free(package_id);
+                                               if (appid_list) g_slist_free(appid_list);
+                                       }, _ACCOUNT_ERROR_NO_DATA, ("pkginfo handle is NULL"));
+
+       ACCOUNT_RETURN_VAL((package_id != NULL), {
+                                               if (phandle) pkgmgrinfo_pkginfo_destroy_pkginfo(phandle);
+                                               if (ahandle) pkgmgrinfo_appinfo_destroy_appinfo(ahandle);
+                                               if (appid_list) g_slist_free(appid_list);
+                                       }, _ACCOUNT_ERROR_NO_DATA, ("package_id is NULL"));
+
+       ACCOUNT_RETURN_VAL((appid_list != NULL), {
+                                               if (phandle) pkgmgrinfo_pkginfo_destroy_pkginfo(phandle);
+                                               if (ahandle) pkgmgrinfo_appinfo_destroy_appinfo(ahandle);
+                                               if (package_id) free(package_id);
+                                       }, _ACCOUNT_ERROR_NO_DATA, ("appid_list is NULL"));
 
        /* Compare current app id with the stored app id family */
        for (iter = appid_list; iter != NULL; iter = g_slist_next(iter)) {