From: Andrii Simiklit Date: Fri, 10 Jan 2020 15:37:13 +0000 (+0200) Subject: mesa/st: fix a memory leak in get_version X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ebaab89761aad59c4debec67c3ec24a96cb82dd1;p=mesa.git mesa/st: fix a memory leak in get_version This patch prevents memory leak in get_version function in st_manager.c This issue was found by valgrind: 16 bytes in 1 blocks are definitely lost in loss record 6 of 1,418 at 0x483CD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x63D9476: st_init_extensions (st_extensions.c:1679) by 0x63B803B: get_version (st_manager.c:1271) by 0x63B8124: st_api_query_versions (st_manager.c:1289) by 0x63266EF: dri_init_screen_helper (dri_screen.c:583) by 0x6321B12: dri2_init_screen (dri2.c:2110) by 0x631AACC: driCreateNewScreen2 (dri_util.c:155) by 0x5D58192: dri3_create_screen (dri3_glx.c:897) by 0x5D39829: AllocAndFetchScreenConfigs (glxext.c:815) by 0x5D39C57: __glXInitialize (glxext.c:941) by 0x5D3290A: GetGLXPrivScreenConfig (glxcmds.c:174) by 0x5D34F38: glXQueryExtensionsString (glxcmds.c:1307) Fixes: eca8032f20d0970184843d98e2bddb688e94a3a9 ("gallium: Add ARB_gl_spirv support") Reviewed-by: Gert Wollny Signed-off-by: Andrii Simiklit Tested-by: Marge Bot Part-of: --- diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index ce7a2f6f0ed..c3688c4818e 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -1269,8 +1269,9 @@ get_version(struct pipe_screen *screen, st_init_limits(screen, &consts, &extensions); st_init_extensions(screen, &consts, &extensions, options, api); - - return _mesa_get_version(&extensions, &consts, api); + version = _mesa_get_version(&extensions, &consts, api); + free(consts.SpirVExtensions); + return version; }