svga: fix shader variant memory leak
authorBrian Paul <brianp@vmware.com>
Thu, 10 Sep 2015 14:47:16 +0000 (08:47 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 10 Sep 2015 18:23:46 +0000 (12:23 -0600)
Fixes a small leak in a seldom-hit corner case for VS/FS compilation.
Found with coverity.

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
src/gallium/drivers/svga/svga_state_fs.c
src/gallium/drivers/svga/svga_state_vs.c

index 849319d3cf3ac13f35dcfaecfd05b5bd83d9a4fa..5d39100f63a8fff8e4022ef99d433ad125becf89 100644 (file)
@@ -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;
index 45dcb5d0f7631bfad0365a37d5fa868edbe913d5..de41519593c2f4fb43b7be8b5b08e07d7637e688 100644 (file)
@@ -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;