From 844bd71736dd59808e1ea4319800db042a7c4267 Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Tue, 30 Jul 2013 22:38:43 -0700 Subject: [PATCH] glsl/linker: Make separate allocations to track vertex and fragment shaders. There's no reason to be clever about this. By making separate allocations for vertex and fragment shaders, we'll allow geometry shaders to be added without introducing any complication. Reviewed-by: Kenneth Graunke --- src/glsl/linker.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 7fae0b8c47d..d7ea740dbf0 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1615,8 +1615,9 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) unsigned num_frag_shaders = 0; vert_shader_list = (struct gl_shader **) - calloc(2 * prog->NumShaders, sizeof(struct gl_shader *)); - frag_shader_list = &vert_shader_list[prog->NumShaders]; + calloc(prog->NumShaders, sizeof(struct gl_shader *)); + frag_shader_list = (struct gl_shader **) + calloc(prog->NumShaders, sizeof(struct gl_shader *)); unsigned min_version = UINT_MAX; unsigned max_version = 0; @@ -1948,6 +1949,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) done: free(vert_shader_list); + free(frag_shader_list); for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { if (prog->_LinkedShaders[i] == NULL) -- 2.30.2