From: jinbong.lee Date: Thu, 31 Oct 2024 05:37:27 +0000 (+0900) Subject: Remove potential crash issue X-Git-Tag: accepted/tizen/unified/x/20241104.122250^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F29%2F319729%2F3;p=platform%2Fcore%2Fuifw%2Flibtpl-egl.git Remove potential crash issue - There is some error when native_dpy is different with wl_display_interface's address - Then, there is no guarantee native_dpy's structure is same with wl_display_interface - So native_dpy's name check should not be run when they has different memory address. Change-Id: I3bb6068186d6282dbbef965acbe0192323dea901 Signed-off-by: jinbong.lee --- diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 5407f9c..a899fd6 100755 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -172,15 +172,14 @@ __tpl_wayland_egl_display_is_wl_display(tpl_handle_t native_dpy) /* MAGIC CHECK: A native display handle is a wl_display if the de-referenced first value is a memory address pointing the structure of wl_display_interface. */ - if (wl_egl_native_dpy == &wl_display_interface) - return TPL_TRUE; + if (wl_egl_native_dpy != &wl_display_interface) + return TPL_FALSE; if (strncmp(wl_egl_native_dpy->name, wl_display_interface.name, - strlen(wl_display_interface.name)) == 0) { - return TPL_TRUE; - } + strlen(wl_display_interface.name)) != 0) + return TPL_FALSE; - return TPL_FALSE; + return TPL_TRUE; } static tpl_result_t diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 893fe78..03b1cd6 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -1358,15 +1358,14 @@ __tpl_display_choose_backend_wl_egl_thread(tpl_handle_t native_dpy) /* MAGIC CHECK: A native display handle is a wl_display if the de-referenced first value is a memory address pointing the structure of wl_display_interface. */ - if (wl_egl_native_dpy == &wl_display_interface) - return TPL_TRUE; + if (wl_egl_native_dpy != &wl_display_interface) + return TPL_FALSE; if (strncmp(wl_egl_native_dpy->name, wl_display_interface.name, - strlen(wl_display_interface.name)) == 0) { - return TPL_TRUE; - } + strlen(wl_display_interface.name)) != 0) + return TPL_FALSE; - return TPL_FALSE; + return TPL_TRUE; } /* -- BEGIN -- wl_egl_window callback functions */ diff --git a/src/tpl_wl_vk_thread.c b/src/tpl_wl_vk_thread.c index d6be95b..ccdd879 100644 --- a/src/tpl_wl_vk_thread.c +++ b/src/tpl_wl_vk_thread.c @@ -99,7 +99,7 @@ struct _tpl_wl_vk_swapchain { tbm_surface_h *swapchain_buffers; - /* [TEMP] To fix dEQP-VK.wsi.wayland.swapchain.modify.resize crash issue + /* [TEMP] To fix dEQP-VK.wsi.wayland.swapchain.modify.resize crash issue * It will be fixed properly using old_swapchain handle */ tbm_surface_h *old_swapchain_buffers; @@ -239,22 +239,16 @@ _check_native_handle_is_wl_display(tpl_handle_t native_dpy) { struct wl_interface *wl_vk_native_dpy = *(void **) native_dpy; - if (!wl_vk_native_dpy) { - TPL_ERR("Invalid parameter. native_display(%p)", wl_vk_native_dpy); - return TPL_FALSE; - } - /* MAGIC CHECK: A native display handle is a wl_display if the de-referenced first value is a memory address pointing the structure of wl_display_interface. */ - if (wl_vk_native_dpy == &wl_display_interface) - return TPL_TRUE; + if (wl_vk_native_dpy != &wl_display_interface) + return TPL_FALSE; if (strncmp(wl_vk_native_dpy->name, wl_display_interface.name, - strlen(wl_display_interface.name)) == 0) { - return TPL_TRUE; - } + strlen(wl_display_interface.name)) != 0) + return TPL_FALSE; - return TPL_FALSE; + return TPL_TRUE; } static tpl_bool_t @@ -1813,7 +1807,7 @@ void __untrack_swapchain_buffers(tpl_wl_vk_surface_t *wl_vk_surface, tbm_surface _get_tbm_surface_bo_name(sc_buffers[i])); tbm_surface_internal_unref(sc_buffers[i]); sc_buffers[i] = NULL; - } + } } }