From f9985db0bc1f1fa217a0fa30a608cb78ccd79a50 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 9 Apr 2014 19:22:11 -0600 Subject: [PATCH] st/mesa: fix sampler_view REALLOC/FREE macro mix-up MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Jakob Bornecrantz --- src/mesa/state_tracker/st_cb_texture.c | 2 +- src/mesa/state_tracker/st_texture.c | 12 ++++++++++++ src/mesa/state_tracker/st_texture.h | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 353415bf2d5..304dc91677e 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -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); } diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 8d559dfcdfd..cfa0605ca2b 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -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); +} diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index 87de9f9f2f4..f2afaf139f1 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -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 -- 2.30.2