[Mesa-dev] [PATCH mesa] egl/wayland: check for invalid format index

Eric Engestrom eric.engestrom at imgtec.com
Thu Feb 15 11:17:29 UTC 2018


CID: 1429516
Fixes: d32b23f3830099a328b91 "egl/wayland: Add bpp to visual map"
Cc: Daniel Stone <daniels at collabora.com>
Signed-off-by: Eric Engestrom <eric.engestrom at imgtec.com>
---
Daniel, `w` seemed like the "least bad" thing to return in this case;
would you prefer `0`?
---
 src/egl/drivers/dri2/platform_wayland.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 20e47a5f6c15129d4fd8..73b29c96e5b83ff184d9 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -1294,6 +1294,11 @@ dri2_wl_swrast_get_stride_for_format(int format, int w)
 {
    int visual_idx = dri2_wl_visual_idx_from_shm_format(format);
 
+   if (visual_idx == -1) {
+      assert(!"unknown format");
+      return w;
+   }
+
    return w * (dri2_wl_visuals[visual_idx].bpp / 8);
 }
 
-- 
Cheers,
  Eric



More information about the mesa-dev mailing list