wayland-client: fix to check if thread_data is valid before accessing it
authorSung-Jin Park <sj76.park@samsung.com>
Tue, 7 Dec 2021 11:17:04 +0000 (20:17 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Thu, 16 Feb 2023 10:12:27 +0000 (19:12 +0900)
Change-Id: Id620472d91f5e493a4de77538ef5e49a3966cefb
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
src/wayland-client.c

index e65c4c9..e36eb38 100644 (file)
@@ -1228,11 +1228,16 @@ get_thread_data(struct wl_display *display)
        thread_data = pthread_getspecific(display->thread_data_key);
        if (!thread_data) {
                wl_list_for_each_safe(th_data, th_data_next, &display->threads, link) {
-                       if (th_data->pid == pid && th_data->tid == tid) {
+                       if (th_data && th_data->pid == pid && th_data->tid == tid) {
                                wl_log("[pid:%d tid:%d] Failed to pthread_getspecific. errno(%d, %m)\n", pid, tid, errno);
                                thread_data = th_data;
                                break;
                        }
+                       if (!th_data && !th_data_next)
+                       {
+                               wl_log("[pid:%d, tid:%d] Invalid thread data stored in threads ! errno(%d, %m)\n", pid, tid, errno);
+                               break;
+                       }
                }
        }