From 46d09cb53dd3de7986e3b4d221d7e3af94752c70 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 2 Apr 2009 11:15:53 -0600 Subject: [PATCH] glsl: fix segfault in linker when vertex or fragment shader was missing --- src/mesa/shader/slang/slang_link.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index e2daf72e7de..1fdf4db054c 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -562,6 +562,9 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType) } } + if (totalLen == 0) + return NULL; + source = (GLchar *) _mesa_malloc(totalLen + 1); if (!source) return NULL; @@ -620,14 +623,16 @@ get_main_shader(GLcontext *ctx, */ shader = concat_shaders(shProg, type); - _slang_compile(ctx, shader); + if (shader) { + _slang_compile(ctx, shader); - /* Finally, check if recompiling failed */ - if (!shader->CompileStatus || - !shader->Main || - shader->UnresolvedRefs) { - link_error(shProg, "Unresolved symbols"); - return NULL; + /* Finally, check if recompiling failed */ + if (!shader->CompileStatus || + !shader->Main || + shader->UnresolvedRefs) { + link_error(shProg, "Unresolved symbols"); + return NULL; + } } return shader; @@ -650,8 +655,8 @@ _slang_link(GLcontext *ctx, GLhandleARB programObj, struct gl_shader_program *shProg) { - const struct gl_vertex_program *vertProg; - const struct gl_fragment_program *fragProg; + const struct gl_vertex_program *vertProg = NULL; + const struct gl_fragment_program *fragProg = NULL; GLuint numSamplers = 0; GLuint i; -- 2.30.2