[Mesa-dev] [PATCH 3/4] svga: fix shader variant memory leak

Brian Paul brianp at vmware.com
Thu Sep 10 08:04:01 PDT 2015


Fixes a small leak in a seldom-hit corner case for VS/FS compilation.
Found with coverity.
---
 src/gallium/drivers/svga/svga_state_fs.c | 3 +++
 src/gallium/drivers/svga/svga_state_vs.c | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/src/gallium/drivers/svga/svga_state_fs.c b/src/gallium/drivers/svga/svga_state_fs.c
index 849319d..5d39100 100644
--- a/src/gallium/drivers/svga/svga_state_fs.c
+++ b/src/gallium/drivers/svga/svga_state_fs.c
@@ -148,6 +148,9 @@ compile_fs(struct svga_context *svga,
                    " using dummy shader instead.\n",
                    (unsigned) (variant->nr_tokens
                                * sizeof(variant->tokens[0])));
+      /* Free the too-large variant */
+      svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_PS, variant);
+      /* Use simple pass-through shader instead */
       variant = get_compiled_dummy_shader(svga, fs, key);
       if (!variant) {
          ret = PIPE_ERROR;
diff --git a/src/gallium/drivers/svga/svga_state_vs.c b/src/gallium/drivers/svga/svga_state_vs.c
index 45dcb5d..de41519 100644
--- a/src/gallium/drivers/svga/svga_state_vs.c
+++ b/src/gallium/drivers/svga/svga_state_vs.c
@@ -139,6 +139,9 @@ compile_vs(struct svga_context *svga,
                    " using dummy shader instead.\n",
                    (unsigned) (variant->nr_tokens
                                * sizeof(variant->tokens[0])));
+      /* Free the too-large variant */
+      svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_VS, variant);
+      /* Use simple pass-through shader instead */
       variant = get_compiled_dummy_vertex_shader(svga, vs, key);
       if (!variant) {
          ret = PIPE_ERROR;
-- 
1.9.1



More information about the mesa-dev mailing list