st/dri: Fix surfaceless gl using contexts with previous bound surfaces
authorBenjamin Franzke <benjaminfranzke@googlemail.com>
Wed, 9 Feb 2011 19:42:50 +0000 (20:42 +0100)
committerKristian Høgsberg <krh@bitplanet.net>
Fri, 11 Feb 2011 04:07:01 +0000 (23:07 -0500)
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;
}

src/gallium/state_trackers/dri/common/dri_context.c

index 3d5d24e692c39d51719067d2943606063e70e18b..999b41152e1de241a56286be60c7ced54217434c 100644 (file)
@@ -169,6 +169,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;
+
    if (ctx->dPriv != driDrawPriv) {
       ctx->dPriv = driDrawPriv;
       draw->texture_stamp = driDrawPriv->lastStamp - 1;
@@ -178,8 +183,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;
 }