util: check for frag/vertShader=0 before attaching
authorBrian Paul <brian.paul@tungstengraphics.com>
Wed, 17 Dec 2008 20:58:05 +0000 (13:58 -0700)
committerBrian Paul <brian.paul@tungstengraphics.com>
Thu, 18 Dec 2008 21:17:06 +0000 (14:17 -0700)
progs/util/shaderutil.c

index 745851395a735ddbacb1e9b5b6571ebbb7957984..2f1c4e38b3004b180d37a38cd4cc9b215ef8c05b 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 
+#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <GL/glut.h>
@@ -106,8 +107,12 @@ LinkShaders(GLuint vertShader, GLuint fragShader)
 {
    GLuint program = glCreateProgram_func();
 
-   glAttachShader_func(program, fragShader);
-   glAttachShader_func(program, vertShader);
+   assert(vertShader || fragShader);
+
+   if (fragShader)
+      glAttachShader_func(program, fragShader);
+   if (vertShader)
+      glAttachShader_func(program, vertShader);
    glLinkProgram_func(program);
 
    /* check link */