From df43fb661b2030d9b833a42dd47b8d7bf58d73aa Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 6 May 2008 23:08:51 -0600 Subject: implement full reference counting for vertex/fragment programs Use _mesa_reference_vert/fragprog() wherever we assign program pointers. Fixes a memory corruption bug found with glean/api2 test. --- src/mesa/shader/slang/slang_link.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/mesa/shader/slang/slang_link.c') diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index c8457fc483d..72fe9997c55 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -516,19 +516,19 @@ _slang_link(GLcontext *ctx, * changing src/dst registers after merging the uniforms and varying vars. */ if (vertProg) { - shProg->VertexProgram - = vertex_program(_mesa_clone_program(ctx, &vertProg->Base)); + _mesa_reference_vertprog(ctx, &shProg->VertexProgram, + vertex_program(_mesa_clone_program(ctx, &vertProg->Base))); } else { - shProg->VertexProgram = NULL; + _mesa_reference_vertprog(ctx, &shProg->VertexProgram, NULL); } if (fragProg) { - shProg->FragmentProgram - = fragment_program(_mesa_clone_program(ctx, &fragProg->Base)); + _mesa_reference_fragprog(ctx, &shProg->FragmentProgram, + fragment_program(_mesa_clone_program(ctx, &fragProg->Base))); } else { - shProg->FragmentProgram = NULL; + _mesa_reference_fragprog(ctx, &shProg->FragmentProgram, NULL); } if (shProg->VertexProgram) @@ -545,10 +545,12 @@ _slang_link(GLcontext *ctx, if (shProg->VertexProgram) { _mesa_free_parameter_list(shProg->VertexProgram->Base.Parameters); shProg->VertexProgram->Base.Parameters = shProg->Uniforms; + assert(shProg->Uniforms); } if (shProg->FragmentProgram) { _mesa_free_parameter_list(shProg->FragmentProgram->Base.Parameters); shProg->FragmentProgram->Base.Parameters = shProg->Uniforms; + assert(shProg->Uniforms); } if (shProg->VertexProgram) { -- cgit v1.2.3