From: Sangyoon Jang Date: Tue, 18 Apr 2017 02:25:22 +0000 (+0900) Subject: Fix a memory leak X-Git-Tag: accepted/tizen/3.0/common/20170605.123857~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e8d9124302327ab529e1cea2f5a8e6ce4de22ef9;p=platform%2Fcore%2Fappfw%2Fapp2sd.git Fix a memory leak Change-Id: I0c6e5cc33442159cbf1630459db4120c203b0420 Signed-off-by: Sangyoon Jang (cherry picked from commit 8e5ef5f85bd99d4e5d8fd1ddd0e1825535e6c176) --- diff --git a/plugin/app2sd/server/app2sd_interface.c b/plugin/app2sd/server/app2sd_interface.c index 88470ea..aa9f152 100644 --- a/plugin/app2sd/server/app2sd_interface.c +++ b/plugin/app2sd/server/app2sd_interface.c @@ -1515,6 +1515,7 @@ int app2sd_pre_migrate_legacy(const char *pkgid, uid_t uid) char mmc_path[FILENAME_MAX] = { 0, }; char file_path[FILENAME_MAX] = { 0, }; uid_t default_uid = tzplatform_getuid(TZ_SYS_DEFAULT_USER); + char *filename; /* check whether MMC is present or not */ ret = _app2sd_check_mmc_status(&sdpath); @@ -1536,7 +1537,8 @@ int app2sd_pre_migrate_legacy(const char *pkgid, uid_t uid) * of legacy image are filled with default user-id, * pkgid(from old db), passwd(from old db) and * empty filename in app2sd db. */ - if (!_app2sd_get_filename_from_db(pkgid, default_uid)) { + filename = _app2sd_get_filename_from_db(pkgid, default_uid); + if (filename == NULL) { passwd = _app2sd_get_password_from_db(pkgid, default_uid); if (passwd) { ret = _app2sd_migrate_legacy_image(pkgid, passwd, @@ -1548,6 +1550,7 @@ int app2sd_pre_migrate_legacy(const char *pkgid, uid_t uid) return APP2EXT_ERROR_INVALID_PACKAGE; } } else { + free(filename); _W("same pkg exists, remove legacy file (%s)", file_path); ret = remove(file_path); if (ret < 0)