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>
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;
}
}
}
- 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;
}
//}
}
- 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;
}
templat.format = format;
templat.bind = bind;
+ pipe_resource_reference(&out[i], NULL);
out[i] = osbuffer->textures[statts[i]] =
screen->resource_create(screen, &templat);
}
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);
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,