[Mesa-dev] [PATCH] st/mesa: Fix a potential memory leak in get_mesa_program.

Vinson Lee vlee at freedesktop.org
Sat Aug 4 14:07:36 PDT 2012


Fixes resource leak defect reported by Coverity.

Signed-off-by: Vinson Lee <vlee at freedesktop.org>
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index fcd69b1..66627ac 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -4790,7 +4790,7 @@ get_mesa_program(struct gl_context *ctx,
                  struct gl_shader_program *shader_program,
                  struct gl_shader *shader)
 {
-   glsl_to_tgsi_visitor* v = new glsl_to_tgsi_visitor();
+   glsl_to_tgsi_visitor* v;
    struct gl_program *prog;
    GLenum target;
    const char *target_string;
@@ -4822,6 +4822,7 @@ get_mesa_program(struct gl_context *ctx,
    if (!prog)
       return NULL;
    prog->Parameters = _mesa_new_parameter_list();
+   v = new glsl_to_tgsi_visitor();
    v->ctx = ctx;
    v->prog = prog;
    v->shader_program = shader_program;
-- 
1.7.11.1



More information about the mesa-dev mailing list