st/mesa: do not call update_framebuffer_size with NULL pointer
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Thu, 20 Sep 2018 08:21:38 +0000 (09:21 +0100)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Thu, 27 Sep 2018 08:33:44 +0000 (10:33 +0200)
In st_renderbuffer_alloc_storage, we avoid allocating storage for
zero-sized buffers, leading to this pointer being NULL. We already
take care to avoid dereferencing these pointers for color-buffers,
but not for depth/stencil-buffers.

So let's thread a bit more carefully here.

This avoids a crash while running Piglit's glx/glx-visuals-stencil
test, both on virgl and r600g.

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Guillaume Charifi <guillaume.charifi@sfr.fr>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/state_tracker/st_atom_framebuffer.c

index 807c312a5dbd74128d8c57dc1dd6dd385a7deda8..a0dd0d1f649d4b015dcfeadf77ef3c63f5d44e45 100644 (file)
@@ -181,7 +181,8 @@ st_update_framebuffer_state( struct st_context *st )
          st_update_renderbuffer_surface(st, strb);
       }
       framebuffer.zsbuf = strb->surface;
-      update_framebuffer_size(&framebuffer, strb->surface);
+      if (strb->surface)
+         update_framebuffer_size(&framebuffer, strb->surface);
    }
    else
       framebuffer.zsbuf = NULL;