mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-09 23:30:13 +01:00
st/mesa: Initialize textures array in st_framebuffer_validate
And just reference pipe_resources to it in the validate callbacks. Avoids pipe_resource leaks when st_framebuffer_validate ends up calling the validate callback multiple times, e.g. when a window is resized. v2: * Use generic stable tag instead of Fixes: tag, since the problem could already happen before the commit referenced in v1 (Thomas Hellstrom) * Use memset to initialize the array on the stack instead of allocating the array with os_calloc. Cc: mesa-stable@lists.freedesktop.org Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
This commit is contained in:
parent
47273d7312
commit
7561da367b
6 changed files with 7 additions and 12 deletions
|
|
@ -99,10 +99,8 @@ dri_st_framebuffer_validate(struct st_context_iface *stctx,
|
|||
return TRUE;
|
||||
|
||||
/* Set the window-system buffers for the state tracker. */
|
||||
for (i = 0; i < count; i++) {
|
||||
out[i] = NULL;
|
||||
for (i = 0; i < count; i++)
|
||||
pipe_resource_reference(&out[i], textures[statts[i]]);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -245,10 +245,8 @@ xmesa_st_framebuffer_validate(struct st_context_iface *stctx,
|
|||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
out[i] = NULL;
|
||||
for (i = 0; i < count; i++)
|
||||
pipe_resource_reference(&out[i], xstfb->textures[statts[i]]);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,10 +193,8 @@ hgl_st_framebuffer_validate(struct st_context_iface *stctxi,
|
|||
//}
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
out[i] = NULL;
|
||||
for (i = 0; i < count; i++)
|
||||
pipe_resource_reference(&out[i], buffer->textures[statts[i]]);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -432,6 +432,7 @@ osmesa_st_framebuffer_validate(struct st_context_iface *stctx,
|
|||
|
||||
templat.format = format;
|
||||
templat.bind = bind;
|
||||
pipe_resource_reference(&out[i], NULL);
|
||||
out[i] = osbuffer->textures[statts[i]] =
|
||||
screen->resource_create(screen, &templat);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,10 +161,8 @@ stw_st_framebuffer_validate(struct st_context_iface *stctx,
|
|||
stwfb->fb->must_resize = FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
out[i] = NULL;
|
||||
for (i = 0; i < count; i++)
|
||||
pipe_resource_reference(&out[i], stwfb->textures[statts[i]]);
|
||||
}
|
||||
|
||||
stw_framebuffer_unlock(stwfb->fb);
|
||||
|
||||
|
|
|
|||
|
|
@ -190,6 +190,8 @@ st_framebuffer_validate(struct st_framebuffer *stfb,
|
|||
if (stfb->iface_stamp == new_stamp)
|
||||
return;
|
||||
|
||||
memset(textures, 0, stfb->num_statts * sizeof(textures[0]));
|
||||
|
||||
/* validate the fb */
|
||||
do {
|
||||
if (!stfb->iface->validate(&st->iface, stfb->iface, stfb->statts,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue