Fix memory leak 80/167080/2
authorSeungha Son <seungha.son@samsung.com>
Mon, 15 Jan 2018 08:40:35 +0000 (17:40 +0900)
committerSeungha Son <seungha.son@samsung.com>
Mon, 15 Jan 2018 09:05:14 +0000 (18:05 +0900)
Signed-off-by: Seungha Son <seungha.son@samsung.com>
Change-Id: I8b6ddb7c8576917662d1788e0f08794c5bc65ef1

src/pkg_upgrade.c

index ebbd787..6ff2bf0 100644 (file)
@@ -876,6 +876,7 @@ static int __process_rw_fota(const char *directory)
                                _LOG("can not get pkg version[%s]\n",
                                        pkg_info->pkgid);
                                pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+                               pkgmgr_client_free_pkginfo(pkg_info);
                                continue;
                        }
 
@@ -889,6 +890,7 @@ static int __process_rw_fota(const char *directory)
                                _LOG("can not compare pkg version[%s]\n",
                                        pkg_info->pkgid);
                                pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+                               pkgmgr_client_free_pkginfo(pkg_info);
                                continue;
                        }
 
@@ -896,6 +898,7 @@ static int __process_rw_fota(const char *directory)
                                /* package version is not update on FOTA. */
                                _LOG("pkg is not updated\n");
                                pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+                               pkgmgr_client_free_pkginfo(pkg_info);
 
                                gettimeofday(&tv, NULL);
                                endtime = tv.tv_sec * 1000l +
@@ -907,7 +910,6 @@ static int __process_rw_fota(const char *directory)
                        }
 
                        _LOG("pkg is updated, need to upgrade\n");
-                       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
                } else {
                        char flag_path[BUF_SIZE] = { 0, };
                        snprintf(flag_path, BUF_SIZE, "%s/%s",
@@ -922,6 +924,7 @@ static int __process_rw_fota(const char *directory)
                                total_time += (int)(endtime - starttime);
                                _LOG("finish request [time : %d ms]\n",
                                        (int)(endtime - starttime));
+                               pkgmgr_client_free_pkginfo(pkg_info);
                                continue;
                        }
 
@@ -936,7 +939,10 @@ static int __process_rw_fota(const char *directory)
                else
                        _LOG("fail request : %d\n", ret);
 
-               pkgmgr_client_free_pkginfo(pkg_info);
+               if (pkg_info)
+                       pkgmgr_client_free_pkginfo(pkg_info);
+               if (handle)
+                       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
 
                gettimeofday(&tv, NULL);
                endtime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;