gallium/osmesa: Fix leak of the ST manager/api on library unload.

Closes: #883
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7886>
This commit is contained in:
Eric Anholt 2020-12-02 15:20:13 -08:00
parent bc3142734e
commit ddbad3f4ea

View file

@ -134,9 +134,26 @@ osmesa_st_get_param(struct st_manager *smapi, enum st_manager_param param)
static struct st_manager *stmgr = NULL;
static struct st_api *stapi = NULL;
static void
destroy_st_manager(void)
{
if (stmgr) {
if (stmgr->screen)
stmgr->screen->destroy(stmgr->screen);
FREE(stmgr);
}
if (stapi && stapi->destroy) {
stapi->destroy(stapi);
}
}
static void
create_st_manager(void)
{
if (atexit(destroy_st_manager) != 0)
return;
stmgr = CALLOC_STRUCT(st_manager);
if (stmgr) {
stmgr->screen = osmesa_create_screen();