egl: extra null checks for get_xcb_screen() return values
verify get_xcb_screen() returned pointer before using it. Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
This commit is contained in:
parent
b9463813ee
commit
4ed23fd590
|
@ -205,6 +205,7 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
|
|||
xcb_screen_iterator_t s;
|
||||
xcb_generic_error_t *error;
|
||||
xcb_drawable_t drawable;
|
||||
xcb_screen_t *screen;
|
||||
|
||||
STATIC_ASSERT(sizeof(uintptr_t) == sizeof(native_surface));
|
||||
drawable = (uintptr_t) native_surface;
|
||||
|
@ -222,11 +223,16 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
|
|||
|
||||
dri2_surf->region = XCB_NONE;
|
||||
if (type == EGL_PBUFFER_BIT) {
|
||||
screen = get_xcb_screen(s, dri2_dpy->screen);
|
||||
if (!screen) {
|
||||
_eglError(EGL_BAD_NATIVE_WINDOW, "dri2_create_surface");
|
||||
goto cleanup_surf;
|
||||
}
|
||||
|
||||
dri2_surf->drawable = xcb_generate_id(dri2_dpy->conn);
|
||||
s = xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy->conn));
|
||||
xcb_create_pixmap(dri2_dpy->conn, conf->BufferSize,
|
||||
dri2_surf->drawable,
|
||||
get_xcb_screen(s, dri2_dpy->screen)->root,
|
||||
dri2_surf->drawable, screen->root,
|
||||
dri2_surf->base.Width, dri2_surf->base.Height);
|
||||
} else {
|
||||
dri2_surf->drawable = drawable;
|
||||
|
@ -504,6 +510,7 @@ dri2_x11_connect(struct dri2_egl_display *dri2_dpy)
|
|||
xcb_dri2_connect_cookie_t connect_cookie;
|
||||
xcb_generic_error_t *error;
|
||||
xcb_screen_iterator_t s;
|
||||
xcb_screen_t *screen;
|
||||
char *driver_name, *device_name;
|
||||
const xcb_query_extension_reply_t *extension;
|
||||
|
||||
|
@ -527,8 +534,12 @@ dri2_x11_connect(struct dri2_egl_display *dri2_dpy)
|
|||
XCB_DRI2_MINOR_VERSION);
|
||||
|
||||
s = xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy->conn));
|
||||
connect_cookie = xcb_dri2_connect_unchecked(dri2_dpy->conn,
|
||||
get_xcb_screen(s, dri2_dpy->screen)->root,
|
||||
screen = get_xcb_screen(s, dri2_dpy->screen);
|
||||
if (!screen) {
|
||||
_eglError(EGL_BAD_NATIVE_WINDOW, "dri2_x11_connect");
|
||||
return EGL_FALSE;
|
||||
}
|
||||
connect_cookie = xcb_dri2_connect_unchecked(dri2_dpy->conn, screen->root,
|
||||
XCB_DRI2_DRIVER_TYPE_DRI);
|
||||
|
||||
xfixes_query =
|
||||
|
@ -589,12 +600,19 @@ dri2_x11_authenticate(_EGLDisplay *disp, uint32_t id)
|
|||
xcb_dri2_authenticate_reply_t *authenticate;
|
||||
xcb_dri2_authenticate_cookie_t authenticate_cookie;
|
||||
xcb_screen_iterator_t s;
|
||||
xcb_screen_t *screen;
|
||||
int ret = 0;
|
||||
|
||||
s = xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy->conn));
|
||||
|
||||
screen = get_xcb_screen(s, dri2_dpy->screen);
|
||||
if (!screen) {
|
||||
_eglError(EGL_BAD_NATIVE_WINDOW, "dri2_x11_authenticate");
|
||||
return -1;
|
||||
}
|
||||
|
||||
authenticate_cookie =
|
||||
xcb_dri2_authenticate_unchecked(dri2_dpy->conn,
|
||||
get_xcb_screen(s, dri2_dpy->screen)->root, id);
|
||||
xcb_dri2_authenticate_unchecked(dri2_dpy->conn, screen->root, id);
|
||||
authenticate =
|
||||
xcb_dri2_authenticate_reply(dri2_dpy->conn, authenticate_cookie, NULL);
|
||||
|
||||
|
|
Loading…
Reference in New Issue