r300g: fix possible crash in destroy_context
authorMarek Olšák <maraeo@gmail.com>
Mon, 19 Jul 2010 18:47:30 +0000 (20:47 +0200)
committerMarek Olšák <maraeo@gmail.com>
Mon, 19 Jul 2010 19:12:52 +0000 (21:12 +0200)
The problem is destroy_context is almost NEVER called.
The only test for destroy_context I know is compiz.

Reported by Vinson Lee.

FDO bug #29150.

src/gallium/drivers/r300/r300_context.c

index 5093c14..df90359 100644 (file)
@@ -122,6 +122,8 @@ static void r300_destroy_context(struct pipe_context* context)
 
     util_mempool_destroy(&r300->pool_transfers);
 
+    r300_update_num_contexts(r300->screen, -1);
+
     FREE(r300->aa_state.state);
     FREE(r300->blend_color_state.state);
     FREE(r300->clip_state.state);
@@ -141,8 +143,6 @@ static void r300_destroy_context(struct pipe_context* context)
         FREE(r300->vertex_stream_state.state);
     }
     FREE(r300);
-
-    r300_update_num_contexts(r300->screen, -1);
 }
 
 void r300_flush_cb(void *data)