[Mesa-dev] [PATCH] glsl_to_tgsi: fix more potential shader reference leaks

Marek Olšák maraeo at gmail.com
Tue Aug 30 08:41:42 PDT 2011


The last one has been pointed out by Ian.
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 3fbb0cd..f1de466 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5035,21 +5035,31 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
                                      (struct gl_vertex_program *)linked_prog);
             ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
                                                  linked_prog);
+            if (!ok) {
+               _mesa_reference_vertprog(ctx, &prog->VertexProgram, NULL);
+            }
             break;
          case GL_FRAGMENT_SHADER:
             _mesa_reference_fragprog(ctx, &prog->FragmentProgram,
                                      (struct gl_fragment_program *)linked_prog);
             ok = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB,
                                                  linked_prog);
+            if (!ok) {
+               _mesa_reference_fragprog(ctx, &prog->FragmentProgram, NULL);
+            }
             break;
          case GL_GEOMETRY_SHADER:
             _mesa_reference_geomprog(ctx, &prog->GeometryProgram,
                                      (struct gl_geometry_program *)linked_prog);
             ok = ctx->Driver.ProgramStringNotify(ctx, GL_GEOMETRY_PROGRAM_NV,
                                                  linked_prog);
+            if (!ok) {
+               _mesa_reference_geomprog(ctx, &prog->GeometryProgram, NULL);
+            }
             break;
          }
          if (!ok) {
+            _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program, NULL);
             _mesa_reference_program(ctx, &linked_prog, NULL);
             return GL_FALSE;
          }
-- 
1.7.4.1



More information about the mesa-dev mailing list