glx/dri3: handle NULL pointers in loader-to-DRI3 drawable conversion
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 27 Jan 2017 10:58:41 +0000 (11:58 +0100)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Mon, 6 Feb 2017 16:39:01 +0000 (17:39 +0100)
With a subsequent patch, we might see NULL loaderPrivates, e.g. when
a DRIdrawable is flushed whose corresponding GLXDRIdrawable was destroyed.
This resulted in a crash, since the loader vs. DRI3 drawable structures
have a non-zero offset.

Fixes glx-visuals-{depth,stencil} -pixmap

Cc: 17.0 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
src/glx/dri3_glx.c

index 4472a0bed2676b3d7b009dcb5d201624dc833f44..f7bcba32f3ee4356f887d71243ac88c3b8c0cda5 100644 (file)
@@ -81,6 +81,8 @@
 static struct dri3_drawable *
 loader_drawable_to_dri3_drawable(struct loader_dri3_drawable *draw) {
    size_t offset = offsetof(struct dri3_drawable, loader_drawable);
+   if (!draw)
+      return NULL;
    return (struct dri3_drawable *)(((void*) draw) - offset);
 }