From f4524771db0242cf3d56a81440de160b57bb3141 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Sun, 13 Nov 2016 16:35:54 +0900 Subject: [PATCH] bugfix related storing external_path and, fix memory leak Change-Id: I0dd633643297daa1dc1db21101eaf8059b6f0d4f Signed-off-by: jongmyeongko --- plugin/app2sd/src/app2sd_interface.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugin/app2sd/src/app2sd_interface.c b/plugin/app2sd/src/app2sd_interface.c index 8bc6b29..40e2cf8 100644 --- a/plugin/app2sd/src/app2sd_interface.c +++ b/plugin/app2sd/src/app2sd_interface.c @@ -874,6 +874,10 @@ int app2sd_usr_pre_move_installed_app(const char *pkgid, /* if move is completed, then update installed storage to pkgmgr_parser db */ if (move_type == APP2EXT_MOVE_TO_EXT) { + if (!image_path) { + _E("image_path is NULL"); + return APP2EXT_ERROR_MEMORY_ALLOC_FAILED; + } pkgmgr_ret = pkgmgrinfo_pkginfo_set_usr_installed_storage(pkgid, INSTALL_EXTERNAL, image_path, uid); if (pkgmgr_ret < 0) { @@ -893,6 +897,9 @@ int app2sd_usr_pre_move_installed_app(const char *pkgid, } } + if (image_path) + free(image_path); + sync(); return APP2EXT_SUCCESS; } @@ -1189,6 +1196,7 @@ int app2sd_usr_post_app_upgrade(const char *pkgid, char *device_name = NULL; char *encoded_id = NULL; int ret = APP2EXT_SUCCESS; + int pkgmgr_ret = 0; /* validate the function parameter recieved */ if (pkgid == NULL || install_status < APP2EXT_STATUS_FAILED @@ -1274,6 +1282,15 @@ int app2sd_usr_post_app_upgrade(const char *pkgid, } #endif + pkgmgr_ret = pkgmgrinfo_pkginfo_set_usr_installed_storage(pkgid, + INSTALL_EXTERNAL, loopback_device, uid); + if (pkgmgr_ret < 0) { + _E("fail to update installed location " \ + "to db[%s, %d] of uid(%d), pkgmgr ret(%d)", + pkgid, INSTALL_EXTERNAL, uid, pkgmgr_ret); + return APP2EXT_ERROR_PKGMGR_ERROR; + } + if (device_name) { free(device_name); device_name = NULL; -- 2.7.4