*
* XXX more checks are needed...
*/
-static void
+static bool
check_resources(const struct gl_context *ctx,
struct gl_shader_program *shader_program,
struct gl_program *prog)
default:
_mesa_problem(ctx, "unexpected program type in check_resources()");
}
+
+ return shader_program->LinkStatus;
}
class add_uniform_to_shader : public uniform_field_visitor {
}
if (!shader_program->LinkStatus) {
- free(mesa_instructions);
- _mesa_reference_program(ctx, &shader->Program, NULL);
- return NULL;
+ goto fail_exit;
}
set_branchtargets(&v, mesa_instructions, num_instructions);
prog->Instructions = mesa_instructions;
prog->NumInstructions = num_instructions;
+ /* Setting this to NULL prevents a possible double free in the fail_exit
+ * path (far below).
+ */
+ mesa_instructions = NULL;
+
do_set_program_inouts(shader->ir, prog, shader->Type == GL_FRAGMENT_SHADER);
count_resources(prog);
- check_resources(ctx, shader_program, prog);
+ if (!check_resources(ctx, shader_program, prog))
+ goto fail_exit;
_mesa_reference_program(ctx, &shader->Program, prog);
}
return prog;
+
+fail_exit:
+ free(mesa_instructions);
+ _mesa_reference_program(ctx, &shader->Program, NULL);
+ return NULL;
}
extern "C" {
_mesa_reference_program(ctx, &linked_prog, NULL);
}
- return GL_TRUE;
+ return prog->LinkStatus;
}