From: Abhishek Vijay Date: Mon, 31 May 2021 12:55:20 +0000 (+0530) Subject: [Non-ACR] memory leak fixes X-Git-Tag: submit/tizen/20210610.065903^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Faccepted%2Ftizen_unified;p=platform%2Fcore%2Faccount%2Faccount-common.git [Non-ACR] memory leak fixes Change-Id: Icfa764547900dd479be66b30d001f2e82ce6691c Signed-off-by: Abhishek Vijay --- diff --git a/common/src/account_db_helper.c b/common/src/account_db_helper.c index c05fd42..a89a628 100644 --- a/common/src/account_db_helper.c +++ b/common/src/account_db_helper.c @@ -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)) {