st/mesa: fix a segfault when prog->sh.data is NULL
authorMarek Olšák <marek.olsak@amd.com>
Thu, 5 Jan 2017 12:47:15 +0000 (13:47 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 5 Jan 2017 16:11:03 +0000 (17:11 +0100)
Broken by:
   st/mesa: get Version from gl_program rather than gl_shader_program

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/mesa/state_tracker/st_atom_texture.c

index 58e753dab641af4d3df080e21530d6ff047ff6d7..76e512f52aaa8f4edd5c7cc980216440514f9f45 100644 (file)
@@ -123,11 +123,13 @@ update_textures(struct st_context *st,
       struct pipe_sampler_view *sampler_view = NULL;
 
       if (samplers_used & 1) {
+         /* prog->sh.data is NULL if it's ARB_fragment_program */
+         unsigned glsl_version = prog->sh.data ? prog->sh.data->Version : 0;
          const GLuint texUnit = prog->SamplerUnits[unit];
          GLboolean retval;
 
          retval = update_single_texture(st, &sampler_view, texUnit,
-                                        prog->sh.data->Version);
+                                        glsl_version);
          if (retval == GL_FALSE)
             continue;