egl/glx/sw: Check xcb_query_extension_reply return value for MIT-SHM
For consistency with other xcb_query_extension_reply callers. v2: * Now with less use-after-free. (Eric Engestrom) Reviewed-by: Eric Engestrom <None> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33400>
This commit is contained in:
@@ -1765,7 +1765,7 @@ check_xshm(struct dri2_egl_display *dri2_dpy)
|
||||
shm_cookie = xcb_query_extension(dri2_dpy->conn, 7, "MIT-SHM");
|
||||
shm_reply = xcb_query_extension_reply(dri2_dpy->conn, shm_cookie, NULL);
|
||||
|
||||
has_mit_shm = shm_reply->present;
|
||||
has_mit_shm = shm_reply && shm_reply->present;
|
||||
free(shm_reply);
|
||||
if (!has_mit_shm)
|
||||
return false;
|
||||
|
||||
@@ -572,16 +572,21 @@ check_xshm(Display *dpy)
|
||||
int ret = True;
|
||||
xcb_query_extension_cookie_t shm_cookie;
|
||||
xcb_query_extension_reply_t *shm_reply;
|
||||
bool has_mit_shm;
|
||||
|
||||
shm_cookie = xcb_query_extension(c, 7, "MIT-SHM");
|
||||
shm_reply = xcb_query_extension_reply(c, shm_cookie, NULL);
|
||||
xshm_opcode = shm_reply->major_opcode;
|
||||
|
||||
has_mit_shm = shm_reply->present;
|
||||
free(shm_reply);
|
||||
if (!has_mit_shm)
|
||||
return False;
|
||||
if (shm_reply) {
|
||||
bool has_mit_shm = shm_reply->present;
|
||||
|
||||
if (has_mit_shm)
|
||||
xshm_opcode = shm_reply->major_opcode;
|
||||
|
||||
free(shm_reply);
|
||||
|
||||
if (!has_mit_shm)
|
||||
return False;
|
||||
}
|
||||
|
||||
cookie = xcb_shm_detach_checked(c, 0);
|
||||
if ((error = xcb_request_check(c, cookie))) {
|
||||
|
||||
Reference in New Issue
Block a user