summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_texture.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2014-04-18 12:20:28 -0600
committerBrian Paul <[email protected]>2014-04-21 08:30:46 -0600
commit27496af67f1a15a3a9aa5d5e09d43d9365101f71 (patch)
tree29b49b64d7782180bab96a4018fbcc5aeb412958 /src/mesa/state_tracker/st_texture.c
parent9fec560e63acd665870db9ab02f702ca677ce910 (diff)
st/mesa: fix invalid pointer use in st_texture_get_sampler_view()
The '**used' pointer was pointing into the stObj->sampler_views array. If 'free' was null, we'd realloc that array, thus making the 'used' pointer invalid. This soon led to memory errors. Just change the pointer to be '*used' so it points directly at the pipe_sampler_view. Reviewed-by: Michel Dänzer <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_texture.c')
-rw-r--r--src/mesa/state_tracker/st_texture.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index f664ef5f140..92035e8016e 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -443,7 +443,7 @@ struct pipe_sampler_view **
st_texture_get_sampler_view(struct st_context *st,
struct st_texture_object *stObj)
{
- struct pipe_sampler_view **used = NULL, **free = NULL;
+ struct pipe_sampler_view *used = NULL, **free = NULL;
GLuint i;
for (i = 0; i < stObj->num_sampler_views; ++i) {
@@ -455,7 +455,7 @@ st_texture_get_sampler_view(struct st_context *st,
return sv;
/* Wasn't the right one, but remember it as template */
- used = sv;
+ used = *sv;
} else {
/* Found a free slot, remember that */
free = sv;
@@ -475,7 +475,7 @@ st_texture_get_sampler_view(struct st_context *st,
/* Add just any sampler view to be used as a template */
if (used)
- pipe_sampler_view_reference(free, *used);
+ pipe_sampler_view_reference(free, used);
return free;
}