mesa/st: Check for a NULL _LinkedShader[i] before using it.
authorStéphane Marchesin <marcheu@chromium.org>
Sun, 9 Oct 2011 23:49:19 +0000 (16:49 -0700)
committerStéphane Marchesin <marcheu@chromium.org>
Mon, 10 Oct 2011 07:15:05 +0000 (00:15 -0700)
The rest of the linker/glsl translation code checks for NULL, so I suppose we should check here too. Fixes crash on exit with i915g instanced drawing.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/state_tracker/st_program.c

index acd3b56b905e7fee437d8a0d76850ed68a9a9d90..c419c4066a1a48a6599edc8328ca3cfb70b05896 100644 (file)
@@ -1154,7 +1154,8 @@ destroy_shader_program_variants_cb(GLuint key, void *data, void *userData)
          }
 
         for (i = 0; i < Elements(shProg->_LinkedShaders); i++) {
-           destroy_program_variants(st, shProg->_LinkedShaders[i]->Program);
+           if (shProg->_LinkedShaders[i])
+               destroy_program_variants(st, shProg->_LinkedShaders[i]->Program);
         }
       }
       break;