main: unreference ATIFragmentShader program before creating new one
authorYevhenii Kolesnikov <yevhenii.kolesnikov@globallogic.com>
Thu, 25 Jul 2019 15:15:24 +0000 (18:15 +0300)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Fri, 26 Jul 2019 12:51:05 +0000 (12:51 +0000)
Old program was overwritten without release of memory.

Signed-off-by: Yevhenii Kolesnikov <yevhenii.kolesnikov@globallogic.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/mesa/main/atifragshader.c

index a9356ae95b17f81be8d8d961cf89988ba04cd584..71c8ce5efdf324d817c0bfaab2dfdd24b0e5abac 100644 (file)
@@ -411,7 +411,10 @@ _mesa_EndFragmentShaderATI(void)
    if (ctx->Driver.NewATIfs) {
       struct gl_program *prog = ctx->Driver.NewATIfs(ctx,
                                                      ctx->ATIFragmentShader.Current);
-      _mesa_reference_program(ctx, &ctx->ATIFragmentShader.Current->Program, prog);
+      _mesa_reference_program(ctx, &ctx->ATIFragmentShader.Current->Program,
+                                   NULL);
+      /* Don't use _mesa_reference_program(), just take ownership */
+      ctx->ATIFragmentShader.Current->Program = prog;
    }
 
    if (!ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_SHADER_ATI,