[Mesa-dev] [PATCH] glsl: avoid leaking linked gl_shader when there's a late linker error
Ilia Mirkin
imirkin at alum.mit.edu
Mon May 25 12:42:16 PDT 2015
ping
On Sun, May 17, 2015 at 5:56 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
>
> Just happened to notice it... still not the leak I'm chasing :( The
> only time this can happen is basically when it's unhappy about the
> clip distance usage (i.e. clipvertex + clipdistance at the same time).
>
> src/glsl/linker.cpp | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
> index 21cfc77..ce43f06 100644
> --- a/src/glsl/linker.cpp
> +++ b/src/glsl/linker.cpp
> @@ -3269,8 +3269,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:
> @@ -3289,8 +3292,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);
> }
> --
> 2.3.6
>
More information about the mesa-dev
mailing list