Fix use after free 72/109572/1 accepted/tizen/3.0/common/20170111.161939 accepted/tizen/3.0/ivi/20170111.090502 accepted/tizen/3.0/mobile/20170111.090307 accepted/tizen/3.0/tv/20170111.090433 accepted/tizen/3.0/wearable/20170111.090447 accepted/tizen/common/20170112.174222 accepted/tizen/ivi/20170111.222028 accepted/tizen/mobile/20170111.221908 accepted/tizen/tv/20170111.221932 accepted/tizen/wearable/20170111.221953 submit/tizen/20170111.041200 submit/tizen_3.0/20170111.022947
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 10 Jan 2017 13:48:31 +0000 (22:48 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 10 Jan 2017 13:48:31 +0000 (22:48 +0900)
Change-Id: If4d8e1da0ac0149fa9499f3d2ac7be2e536e9714
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/app_context.c

index 2eed5fe..04d06c8 100644 (file)
@@ -202,7 +202,7 @@ static int app_context_retrieve_app_context(const aul_app_info *aul_app_context,
                        app_state = app_context_get_app_status(aul_app_context->status);
 
                        retrieval_context->pid = aul_app_context->pid;
-                       retrieval_context->pkg_id = aul_app_context->pkgid;
+                       retrieval_context->pkg_id = strdup(aul_app_context->pkgid);
                        retrieval_context->app_state = app_state;
                        if (aul_app_context->is_sub_app)
                                retrieval_context->is_sub_app = true;
@@ -215,6 +215,7 @@ static int app_context_retrieve_app_context(const aul_app_info *aul_app_context,
 
 int app_context_get_app_context(const char *app_id, app_context_h *app_context)
 {
+       int ret;
        retrieval_context_s retrieval_context =  {
                .app_id = app_id,
                .pid = 0,
@@ -235,13 +236,15 @@ int app_context_get_app_context(const char *app_id, app_context_h *app_context)
        if (retrieval_context.matched == false)
                return app_manager_error(APP_MANAGER_ERROR_NO_SUCH_APP, __FUNCTION__, NULL);
 
-
-       return app_context_create(retrieval_context.app_id,
+       ret = app_context_create(retrieval_context.app_id,
                                        retrieval_context.pid,
                                        retrieval_context.pkg_id,
                                        retrieval_context.app_state,
                                        retrieval_context.is_sub_app,
                                         app_context);
+       free(retrieval_context.pkg_id);
+
+       return ret;
 }
 
 static int app_context_create(const char *app_id, pid_t pid, const char *pkg_id, app_state_e app_state, bool is_sub_app, app_context_h *app_context)