Remove potential crash issue 29/319729/3 accepted/tizen/unified/20241108.105410 accepted/tizen/unified/x/20241104.122250
authorjinbong.lee <jinbong.lee@samsung.com>
Thu, 31 Oct 2024 05:37:27 +0000 (14:37 +0900)
committerjinbong.lee <jinbong.lee@samsung.com>
Thu, 31 Oct 2024 07:06:36 +0000 (16:06 +0900)
  - 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 <jinbong.lee@samsung.com>
src/tpl_wayland_egl.c
src/tpl_wl_egl_thread.c
src/tpl_wl_vk_thread.c

index 5407f9c1c92667c50f6723b09feeb70318bc824b..a899fd624b841ed4e036ceedf707f21d9e62f99b 100755 (executable)
@@ -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
index 893fe78450e3b927d98cf855a1ef3885d4beda9f..03b1cd66d3f2ec7e534545bdf6673a8e730039b6 100755 (executable)
@@ -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 */
index d6be95b69950ea8cd36f1ef22a093d221b3af8fa..ccdd879cd4ec7b77bd859746d6d129696e7abf6b 100644 (file)
@@ -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;
-               }               
+               }
        }
 }