Module: Mesa
Branch: main
Commit: 84527093c40f832e71b39225aeefe1276670f37b
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=84527093c40f832e71b39225aeefe1276670f37b

Author: Vinson Lee <[email protected]>
Date:   Sun Jan  8 11:53:57 2023 -0800

spirv2dxil: Fix memory leak on error path.

Fix resource leak reported by Coverity Scan.

Resource leak (RESOURCE_LEAK)
leaked_storage: Variable file_contents going out of scope leaks the storage it 
points to.

Fixes: 531d17c3342 ("spirv2dxil: Support linking multiple shaders")
Signed-off-by: Vinson Lee <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20576>

---

 src/microsoft/spirv_to_dxil/spirv2dxil.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/microsoft/spirv_to_dxil/spirv2dxil.c 
b/src/microsoft/spirv_to_dxil/spirv2dxil.c
index c5be7649b78..a468f308b23 100644
--- a/src/microsoft/spirv_to_dxil/spirv2dxil.c
+++ b/src/microsoft/spirv_to_dxil/spirv2dxil.c
@@ -92,6 +92,7 @@ compile_shader(const char *filename, gl_shader_stage 
shader_stage, struct shader
    if (file_size % WORD_SIZE != 0) {
       fprintf(stderr, "%s size == %zu is not a multiple of %d\n", filename,
               file_size, WORD_SIZE);
+      free(file_contents);
       return false;
    }
 

Reply via email to