gallium/osmesa: fix buffer resizing

Generate a new buffer if OSMesaMakeCurrent is called with a new size
Fix a use-after-free error when the old buffer is destroyed

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5276
Fixes: 26c6f6cfbb ("gallium/osmesa: Remove the broken buffer-reuse scheme.")
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12685>
This commit is contained in:
mattvchandler 2021-09-01 09:44:12 -08:00 committed by Marge Bot
parent 3b289c9f30
commit eed660221b

View file

@ -781,8 +781,11 @@ OSMesaMakeCurrent(OSMesaContext osmesa, void *buffer, GLenum type,
if (osmesa->current_buffer &&
(osmesa->current_buffer->visual.color_format != color_format ||
osmesa->current_buffer->visual.depth_stencil_format != osmesa->depth_stencil_format ||
osmesa->current_buffer->visual.accum_format != osmesa->accum_format)) {
osmesa->current_buffer->visual.accum_format != osmesa->accum_format ||
osmesa->current_buffer->width != width ||
osmesa->current_buffer->height != height)) {
osmesa_destroy_buffer(osmesa->current_buffer);
osmesa->current_buffer = NULL;
}
if (!osmesa->current_buffer) {