bugfix related storing external_path 90/97290/3 accepted/tizen/3.0/common/20161114.142941 accepted/tizen/3.0/ivi/20161114.002555 accepted/tizen/3.0/mobile/20161114.002431 accepted/tizen/3.0/tv/20161114.002506 accepted/tizen/3.0/wearable/20161114.002530 accepted/tizen/common/20161125.095235 accepted/tizen/ivi/20161125.004201 accepted/tizen/mobile/20161125.003639 accepted/tizen/tv/20161125.003920 accepted/tizen/wearable/20161125.004042 submit/tizen/20161124.000829 submit/tizen_3.0/20161111.080112 submit/tizen_3.0_common/20161114.081136
authorjongmyeongko <jongmyeong.ko@samsung.com>
Sun, 13 Nov 2016 07:35:54 +0000 (16:35 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Sun, 13 Nov 2016 08:45:13 +0000 (17:45 +0900)
and, fix memory leak

Change-Id: I0dd633643297daa1dc1db21101eaf8059b6f0d4f
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
plugin/app2sd/src/app2sd_interface.c

index 8bc6b29..40e2cf8 100644 (file)
@@ -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;