From ec56cc4a5d03c6f283099ddca389d69fc309902f Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Fri, 1 Feb 2019 15:30:45 +0100 Subject: [PATCH] shader: free stale sampler_arrays in sinfo (v2) Fixes the mem leak: Direct leak of 8 byte(s) in 1 object(s) allocated from: #0 0x7f49a7733c60 in realloc (/usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.0/libasan.so+0xdbc60) #1 0x7f49a713100a in add_sampler_array ../../../../virgl-gitlab/src/vrend_shader.c:619 #2 0x7f49a71318cb in add_samplers ../../../../virgl-gitlab/src/vrend_shader.c:677 #3 0x7f49a713a780 in iter_declaration ../../../../virgl-gitlab/src/vrend_shader.c:1213 #4 0x7f49a7194c37 in tgsi_iterate_shader ../../../../../../virgl-gitlab/src/gallium/auxiliary/tgsi/tgsi_iterate.c:59 #5 0x7f49a7169a24 in vrend_convert_shader ../../../../virgl-gitlab/src/vrend_shader.c:5012 Closes: #85 [airlied: v2: free image arrays as well] Signed-off-by: Gert Wollny Signed-off-by: Dave Airlie --- src/vrend_shader.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vrend_shader.c b/src/vrend_shader.c index 5713e15..ed1a4eb 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -5098,8 +5098,12 @@ char *vrend_convert_shader(struct vrend_context *rctx, sinfo->so_names = ctx.so_names; sinfo->attrib_input_mask = ctx.attrib_input_mask; + if (sinfo->sampler_arrays) + free(sinfo->sampler_arrays); sinfo->sampler_arrays = ctx.sampler_arrays; sinfo->num_sampler_arrays = ctx.num_sampler_arrays; + if (sinfo->image_arrays) + free(sinfo->image_arrays); sinfo->image_arrays = ctx.image_arrays; sinfo->num_image_arrays = ctx.num_image_arrays; return glsl_final;