From: Hwankyu Jhun Date: Tue, 10 Jan 2017 13:48:31 +0000 (+0900) Subject: Fix use after free X-Git-Tag: submit/tizen_3.0/20170111.022947^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=50ff945bad0cfbdd32e89af5da66c5eeccddcc9b;p=platform%2Fcore%2Fapi%2Fapp-manager.git Fix use after free Change-Id: If4d8e1da0ac0149fa9499f3d2ac7be2e536e9714 Signed-off-by: Hwankyu Jhun --- diff --git a/src/app_context.c b/src/app_context.c index 2eed5fe..04d06c8 100644 --- a/src/app_context.c +++ b/src/app_context.c @@ -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)