st/mesa: fix sampler_view REALLOC/FREE macro mix-up
authorBrian Paul <brianp@vmware.com>
Thu, 10 Apr 2014 01:22:11 +0000 (19:22 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 10 Apr 2014 13:53:05 +0000 (07:53 -0600)
We were using REALLOC() from u_memory.h but FREE() from imports.h.
This mismatch caused us to trash the heap on Windows after we
deleted a texture object.

This fixes a regression from commit 6c59be7776e4d.

Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_texture.c
src/mesa/state_tracker/st_texture.h

index 353415bf2d53f01ff2d3cfc85350a4b132c5a861..304dc91677eb61fcd2365db98b0387310be4779d 100644 (file)
@@ -155,7 +155,7 @@ st_DeleteTextureObject(struct gl_context *ctx,
 
    pipe_resource_reference(&stObj->pt, NULL);
    st_texture_release_all_sampler_views(stObj);
-   FREE(stObj->sampler_views);
+   st_texture_free_sampler_views(stObj);
    _mesa_delete_texture_object(ctx, texObj);
 }
 
index 8d559dfcdfd21f35f6110c73ed59e32ddabb869d..cfa0605ca2b15446d707a8b9357635c9e0d9a64d 100644 (file)
@@ -483,3 +483,15 @@ st_texture_release_all_sampler_views(struct st_texture_object *stObj)
    for (i = 0; i < stObj->num_sampler_views; ++i)
       pipe_sampler_view_reference(&stObj->sampler_views[i], NULL);
 }
+
+
+void
+st_texture_free_sampler_views(struct st_texture_object *stObj)
+{
+   /* NOTE:
+    * We use FREE() here to match REALLOC() above.  Both come from
+    * u_memory.h, not imports.h.  If we mis-match MALLOC/FREE from
+    * those two headers we can trash the heap.
+    */
+   FREE(stObj->sampler_views);
+}
index 87de9f9f2f4e2986a69bed21435ffcaa126b5998..f2afaf139f1c4f388e223dcefc16caae527d6b6b 100644 (file)
@@ -241,4 +241,7 @@ st_texture_release_sampler_view(struct st_context *st,
 extern void
 st_texture_release_all_sampler_views(struct st_texture_object *stObj);
 
+void
+st_texture_free_sampler_views(struct st_texture_object *stObj);
+
 #endif