From 141e35fbe4f3e9b3d9f6165fdca34a049a61df4b Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Mon, 17 Jan 2022 18:19:40 +0900 Subject: Fix resource leak and potential crash Change-Id: Id593b90c637914789f4fbd8a528193670726e1b2 Signed-off-by: Yunjin Lee --- ui-popup/src/popup.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ui-popup/src/popup.c b/ui-popup/src/popup.c index 74af91f..59dfbf8 100644 --- a/ui-popup/src/popup.c +++ b/ui-popup/src/popup.c @@ -174,17 +174,20 @@ static char* __get_pkg_label(const char* pkgid) int ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle); if (ret != PMINFO_R_OK) { LOGE("pkgmgrinfo_pkginfo_get_pkginfo() failed. ret = %d, pkgid = %s", ret, pkgid); - return ""; + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return strdup(""); } ret = pkgmgrinfo_pkginfo_get_label(handle, &label); if (ret != PMINFO_R_OK) { LOGE("pkgmgrinfo_pkginfo_get_label() failed. ret = %d, pkgid = %s", ret, pkgid); - return ""; + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return strdup(""); } char* pkg_label = strdup(label); if (pkg_label == NULL) { LOGE("strdup() of pkg_label failed. pkgid = %s", pkgid); - return ""; + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return strdup(""); } pkgmgrinfo_pkginfo_destroy_pkginfo(handle); -- cgit v1.2.3