diff options
author | Brian Paul <[email protected]> | 2009-04-02 11:15:53 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-04-02 11:15:53 -0600 |
commit | 46d09cb53dd3de7986e3b4d221d7e3af94752c70 (patch) | |
tree | 206d9040acfd271b72c3e08f5465560f772c2a3e | |
parent | 29a1ed599b0cde4b9cf4d83ffe559854ea91b304 (diff) |
glsl: fix segfault in linker when vertex or fragment shader was missing
-rw-r--r-- | src/mesa/shader/slang/slang_link.c | 23 |
1 files 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; |