summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlia Mirkin <[email protected]>2015-05-17 17:56:44 -0400
committerEmil Velikov <[email protected]>2015-06-03 11:52:50 +0100
commitadee8f1ca5ba636b6ab996b2a05b9516a74e04a5 (patch)
treec0371fbb776db7db352c0cb4758e2086e4bae293
parent56d13627ebb07cac52401714f11a92be6b2d34e6 (diff)
glsl: avoid leaking linked gl_shader when there's a late linker error
This makes piglit mixing-clip-distance-and-clip-vertex-disallowed have 0 definitely lost blocks with valgrind. (Same non-0 number of possibly lost blocks though.) Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Tobias Klausmann <[email protected]> Cc: "10.5 10.6" <[email protected]> (cherry picked from commit 5646f0f18a620292524eebcd77353ff3d3687eb2)
-rw-r--r--src/glsl/linker.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 01526de56c6..ef815aec5f1 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -2570,8 +2570,11 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
link_intrastage_shaders(mem_ctx, ctx, prog, shader_list[stage],
num_shaders[stage]);
- if (!prog->LinkStatus)
+ if (!prog->LinkStatus) {
+ if (sh)
+ ctx->Driver.DeleteShader(ctx, sh);
goto done;
+ }
switch (stage) {
case MESA_SHADER_VERTEX:
@@ -2584,8 +2587,11 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
validate_fragment_shader_executable(prog, sh);
break;
}
- if (!prog->LinkStatus)
+ if (!prog->LinkStatus) {
+ if (sh)
+ ctx->Driver.DeleteShader(ctx, sh);
goto done;
+ }
_mesa_reference_shader(ctx, &prog->_LinkedShaders[stage], sh);
}