st/mesa: remove redundant stfb->iface checks
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 21 Apr 2017 13:11:34 +0000 (15:11 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 28 Apr 2017 09:34:00 +0000 (11:34 +0200)
stfb->iface is always non-NULL for an st_framebuffer. These checks
were incorrect, relying on out-of-bounds memory access in the
surface-less case of EGL_KHR_surfaceless_context.

v2: remove redundant stread check (Marek)

Reviewed-by: Marek Olšák <marek@olsak@amd.com> (v2)
src/mesa/state_tracker/st_cb_viewport.c
src/mesa/state_tracker/st_manager.c

index ff18fd0e6a48b4f155d5da828938c83bed1c8e79..8b50350fabba1ebf64d9c17acfb6c1f85df9a292 100644 (file)
@@ -54,9 +54,9 @@ static void st_viewport(struct gl_context *ctx)
    stdraw = st_ws_framebuffer(st->ctx->DrawBuffer);
    stread = st_ws_framebuffer(st->ctx->ReadBuffer);
 
-   if (stdraw && stdraw->iface)
+   if (stdraw)
       stdraw->iface_stamp = p_atomic_read(&stdraw->iface->stamp) - 1;
-   if (stread && stread != stdraw && stread->iface)
+   if (stread && stread != stdraw)
       stread->iface_stamp = p_atomic_read(&stread->iface->stamp) - 1;
 }
 
index 2ba7de6c6346d0e2d76fe974de3ddf54f1265cc2..90e4177f69646459422b866369ddffa9f70c4c8a 100644 (file)
@@ -176,10 +176,6 @@ st_framebuffer_validate(struct st_framebuffer *stfb,
    boolean changed = FALSE;
    int32_t new_stamp;
 
-   /* Check for incomplete framebuffers (e.g. EGL_KHR_surfaceless_context) */
-   if (!stfb->iface)
-      return;
-
    new_stamp = p_atomic_read(&stfb->iface->stamp);
    if (stfb->iface_stamp == new_stamp)
       return;
@@ -281,9 +277,6 @@ st_framebuffer_add_renderbuffer(struct st_framebuffer *stfb,
    enum pipe_format format;
    boolean sw;
 
-   if (!stfb->iface)
-      return FALSE;
-
    assert(_mesa_is_winsys_fbo(&stfb->Base));
 
    /* do not distinguish depth/stencil buffers */