egl/wayland: Don't segfault if create_wl_buffer returns NULL

Normally, this shouldn't fail, but it has various cases where it returns
`NULL`. Without this change, it would result in a segfault when
`wl_buffer_add_listener` is called.

This instead makes `EGLSwapBuffers` return a `EGL_BAD_ALLOC` error.

The other place `create_wl_buffer` is called already checks the return
value, and the Vulkan WSI code doesn't seem to have an issue like this.

Signed-off-by: Ian Douglas Scott <ian@iandouglasscott.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24915>
This commit is contained in:
Ian Douglas Scott
2023-08-28 16:18:01 -07:00
committed by Marge Bot
parent 82e342888f
commit 1950481d08

View File

@@ -1602,6 +1602,9 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp, _EGLSurface *draw,
dri2_surf->current->wl_buffer =
create_wl_buffer(dri2_dpy, dri2_surf, image);
if (dri2_surf->current->wl_buffer == NULL)
return _eglError(EGL_BAD_ALLOC, "dri2_swap_buffers");
dri2_surf->current->wl_release = false;
wl_buffer_add_listener(dri2_surf->current->wl_buffer, &wl_buffer_listener,