st/mesa: Fix a potential memory leak in get_mesa_program.
authorVinson Lee <vlee@freedesktop.org>
Sat, 4 Aug 2012 21:04:03 +0000 (14:04 -0700)
committerVinson Lee <vlee@freedesktop.org>
Tue, 7 Aug 2012 05:08:56 +0000 (22:08 -0700)
Fixes resource leak defect reported by Coverity.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index fcd69b18d3aecc25ffd5176c006073475927376e..66627acb6fc27024d2df478720939c120eaa2d00 100644 (file)
@@ -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;