Mesa (staging/21.0): egl/x11: don't forget to exit the attrib list loop

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed May 19 23:16:02 UTC 2021


Module: Mesa
Branch: staging/21.0
Commit: ba499499c523ccfb6c40944fdd034287179fba7a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ba499499c523ccfb6c40944fdd034287179fba7a

Author: Eric Engestrom <eric at engestrom.ch>
Date:   Sun May  9 18:10:32 2021 +0200

egl/x11: don't forget to exit the attrib list loop

Without this check, if we receive any attribs from the client, we either
find an X11/XCB screen fd in there, or we keep going until we end up in
random bits of memory and crash.

Fixes: 4aebd86f9a1b0db0ebcc ("egl/x11: pick the user requested screen")
Signed-off-by: Eric Engestrom <eric at engestrom.ch>
Reviewed-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10717>
(cherry picked from commit 2af08bf7b69a5f3b8f94b8669f1bff67405ca396)

---

 .pick_status.json                   | 2 +-
 src/egl/drivers/dri2/platform_x11.c | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 091d8e2b378..e21ea003fe6 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -3082,7 +3082,7 @@
         "description": "egl/x11: don't forget to exit the attrib list loop",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "4aebd86f9a1b0db0ebcc69c30c00f0981a28e6a6"
     },
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index 9ffd67ab58c..5ffdf132184 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -1211,7 +1211,10 @@ dri2_find_screen_for_display(const _EGLDisplay *disp, int fallback_screen)
 {
    const EGLAttrib *attr;
 
-   for (attr = disp->Options.Attribs; attr; attr += 2) {
+   if (!disp->Options.Attribs)
+      return fallback_screen;
+
+   for (attr = disp->Options.Attribs; attr[0] != EGL_NONE; attr += 2) {
       if (attr[0] == EGL_PLATFORM_X11_SCREEN_EXT ||
           attr[0] == EGL_PLATFORM_XCB_SCREEN_EXT)
          return attr[1];



More information about the mesa-commit mailing list