From: Hyunho Kang Date: Fri, 11 Nov 2016 02:52:40 +0000 (+0900) Subject: Fix deref after null issue X-Git-Tag: submit/tizen/20161111.080541~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F14%2F97014%2F2;p=platform%2Fcore%2Fappfw%2Faul-1.git Fix deref after null issue Change-Id: Iab2a69c1f4d581d1336192ba53f9fc9a1ea318c9 Signed-off-by: Hyunho Kang --- diff --git a/src/aul_rsm.c b/src/aul_rsm.c index 7a0a770..c71262d 100644 --- a/src/aul_rsm.c +++ b/src/aul_rsm.c @@ -174,6 +174,7 @@ static const struct tizen_remote_surface_provider_listener __rsp_listener = { API int aul_rsm_provider_remote_enable(const char *id, struct wl_surface *surface) { struct __remote_surface_s *remote; + struct wl_display *display; if (!__rsm) { _E("__rsm is not ready"); @@ -185,6 +186,12 @@ API int aul_rsm_provider_remote_enable(const char *id, struct wl_surface *surfac return -1; } + display = ecore_wl_display_get(); + if (!display) { + _E("Fail to get"); + return -1; + } + remote = (struct __remote_surface_s *)malloc(sizeof(struct __remote_surface_s)); if (!remote) { _E("out of memory"); @@ -195,24 +202,27 @@ API int aul_rsm_provider_remote_enable(const char *id, struct wl_surface *surfac remote->win = ecore_wl_window_surface_find(surface); if (!remote->win) { _E("failed to find win"); + free(remote); return -1; } remote->rsp = tizen_remote_surface_manager_create_provider(__rsm, surface); if (!remote->rsp) { _E("failed to create provider"); + free(remote); return -1; } remote->id = strdup(id); if (!remote->id) { + free(remote); _E("out of memory"); return -1; } tizen_remote_surface_provider_add_listener(remote->rsp, &__rsp_listener, remote); - wl_display_roundtrip(ecore_wl_display_get()); + wl_display_roundtrip(display); _D("%d surface remote enable"); return 0; @@ -268,16 +278,15 @@ static int __tbm_handler(const char *endpoint, aul_app_com_result_e e, if (pid != NULL) surface->pid = (int)*pid; - surface->resource_id = *res_id; - surface->surface = tizen_remote_surface_manager_create_surface(__rsm, - (uint32_t)*res_id, __tbm); - - _D("__tbm_handler %d, %d, %s", *pid, *res_id, id); - - if (id && res_id) + if (res_id != NULL) { + surface->resource_id = *res_id; + surface->surface = tizen_remote_surface_manager_create_surface(__rsm, + (uint32_t)surface->resource_id, __tbm); __redirect_surface(surface); - else + } else { _E("bad tbm message received. missing arguments"); + } + _D("__tbm_handler %d, %d, %s", surface->pid, surface->resource_id, id); return 0; } @@ -362,7 +371,8 @@ API int aul_rsm_viewer_set_surface_handler_by_rid(int resource_id, aul_rsm_handl snprintf(buf, sizeof(buf), "%d", resource_id); aul_rsm_viewer_set_surface_handler(buf, cbs, data); surface = g_hash_table_lookup(__viewer_tbl, buf); - __redirect_surface(surface); + if (surface) + __redirect_surface(surface); return 0; }