From: Eric Anholt Date: Wed, 2 Dec 2020 23:20:13 +0000 (-0800) Subject: gallium/osmesa: Fix leak of the ST manager/api on library unload. X-Git-Tag: upstream/21.0.0~1666 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ddbad3f4eae3e3b2ed41d8c541c01a0fb21a6e90;p=platform%2Fupstream%2Fmesa.git gallium/osmesa: Fix leak of the ST manager/api on library unload. Closes: #883 Reviewed-by: Adam Jackson Part-of: --- diff --git a/src/gallium/frontends/osmesa/osmesa.c b/src/gallium/frontends/osmesa/osmesa.c index 5ce5f7b..5c7f27d 100644 --- a/src/gallium/frontends/osmesa/osmesa.c +++ b/src/gallium/frontends/osmesa/osmesa.c @@ -135,8 +135,25 @@ 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();