glsl_to_tgsi: fix more potential shader reference leaks
authorMarek Olšák <maraeo@gmail.com>
Tue, 30 Aug 2011 15:11:34 +0000 (17:11 +0200)
committerMarek Olšák <maraeo@gmail.com>
Fri, 2 Sep 2011 20:39:56 +0000 (22:39 +0200)
The last one has been pointed out by Ian.

src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index 31750686e9825182f2d5efdb0fb6623def23c58d..66fc00f816138ce9f912cf9b181267a18bdfbb3f 100644 (file)
@@ -5078,21 +5078,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;
          }