Mesa (7.10): st/dri: Fix surfaceless gl using contexts with previous bound surfaces

Jakob Bornecrantz wallbraker at kemper.freedesktop.org
Wed Mar 30 00:27:36 UTC 2011


Module: Mesa
Branch: 7.10
Commit: 71b06c63ce4a5f58ceb72725d8320bc735997241
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=71b06c63ce4a5f58ceb72725d8320bc735997241

Author: Benjamin Franzke <benjaminfranzke at googlemail.com>
Date:   Wed Feb  9 20:42:50 2011 +0100

st/dri: Fix surfaceless gl using contexts with previous bound surfaces

ctx->dPriv might be != NULL then draw which is NULL is accessed:

struct dri_drawable *draw = dri_drawable(driDrawPriv);
[..]
if (ctx->dPriv != driDrawPriv) {
      ctx->dPriv = driDrawPriv;
      draw->texture_stamp = driDrawPriv->lastStamp - 1;
}

Cherry-picked from 0acb31be171f01aec8b38ceaddf47b7da6dae2a0

Signed-off-by: Jakob Bornecrantz <wallbraker at gmail.com>

---

 .../state_trackers/dri/common/dri_context.c        |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/dri/common/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c
index aef1892..fc68ee1 100644
--- a/src/gallium/state_trackers/dri/common/dri_context.c
+++ b/src/gallium/state_trackers/dri/common/dri_context.c
@@ -175,6 +175,11 @@ dri_make_current(__DRIcontext * cPriv,
 
    ++ctx->bind_count;
 
+   if (!driDrawPriv && !driReadPriv)
+      return ctx->stapi->make_current(ctx->stapi, ctx->st, NULL, NULL);
+   else if (!driDrawPriv || !driReadPriv)
+      return GL_FALSE;
+
    draw->context = ctx;
    if (ctx->dPriv != driDrawPriv) {
       ctx->dPriv = driDrawPriv;
@@ -186,8 +191,7 @@ dri_make_current(__DRIcontext * cPriv,
       read->texture_stamp = driReadPriv->lastStamp - 1;
    }
 
-   ctx->stapi->make_current(ctx->stapi, ctx->st,
-         (draw) ? &draw->base : NULL, (read) ? &read->base : NULL);
+   ctx->stapi->make_current(ctx->stapi, ctx->st, &draw->base, &read->base);
 
    return GL_TRUE;
 }




More information about the mesa-commit mailing list