[Mesa-dev] [PATCH 2/2] mesa: free gl_uniform_storage::name

Pekka Paalanen ppaalanen at gmail.com
Wed Dec 14 23:26:30 PST 2011


parcel_out_uniform_storage::visit_field() assigns a strdup()'d string
into gl_uniform_storage::name, but it is never freed.

Free gl_uniform_storage::name, fixes some Valgrind reported memory
leaks.

Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
 src/mesa/main/shaderobj.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index 454007f..2275430 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -39,6 +39,7 @@
 #include "program/prog_parameter.h"
 #include "program/hash_table.h"
 #include "ralloc.h"
+#include "../glsl/ir_uniform.h"
 
 /**********************************************************************/
 /*** Shader object functions                                        ***/
@@ -276,6 +277,9 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
                                 struct gl_shader_program *shProg)
 {
    if (shProg->UniformStorage) {
+      unsigned i;
+      for (i = 0; i < shProg->NumUserUniformStorage; ++i)
+         free(shProg->UniformStorage[i].name);
       ralloc_free(shProg->UniformStorage);
       shProg->NumUserUniformStorage = 0;
       shProg->UniformStorage = NULL;
-- 
1.7.3.4



More information about the mesa-dev mailing list