Add app_context_destroy() to remove memory leak 91/255991/2
authorSuyeon Hwang <stom.hwang@samsung.com>
Fri, 26 Mar 2021 06:45:48 +0000 (15:45 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Fri, 26 Mar 2021 07:55:08 +0000 (16:55 +0900)
Change-Id: I515dc3093b77276a802bfbd1230a8f687456b829
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
common/vc_cmd_db.c
server/vcd_server.c

index 4450794..c5004ef 100644 (file)
@@ -596,14 +596,13 @@ static int __vc_db_get_pid(const char* appid, int* pid)
                }
 
                ret = app_context_get_pid(app_context, pid);
-               if (APP_MANAGER_ERROR_NONE != ret) {
-                       SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to get pid, ret(%d), appid(%s)", ret, appid);
-                       return VC_DB_ERROR_OPERATION_FAILED;
+               int destroy_ret = app_context_destroy(app_context);
+               if (APP_MANAGER_ERROR_NONE != destroy_ret) {
+                       SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to destroy app context, ret(%d), appid(%s)", destroy_ret, appid);
                }
 
-               ret = app_context_destroy(app_context);
                if (APP_MANAGER_ERROR_NONE != ret) {
-                       SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to destroy app context, ret(%d), appid(%s)", ret, appid);
+                       SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to get pid, ret(%d), appid(%s)", ret, appid);
                        return VC_DB_ERROR_OPERATION_FAILED;
                }
        } else {
index cd5e3b4..721b265 100755 (executable)
@@ -283,10 +283,16 @@ static int __vcd_resume_app(const char* appid)
        }
 
        ret = app_manager_resume_app(app_context);
+       int destroy_ret = app_context_destroy(app_context);
+       if (APP_MANAGER_ERROR_NONE != destroy_ret) {
+               SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to destroy app_context, ret(%d), appid(%s)", destroy_ret, appid);
+       }
+
        if (APP_MANAGER_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to resume app, ret(%d), appid(%s)", ret, appid);
                return VCD_ERROR_OPERATION_FAILED;
        }
+
        return VCD_ERROR_NONE;
 }