[Mesa-dev] [PATCH] st/mesa: fix a segfault when prog->sh.data is NULL

Marek Olšák maraeo at gmail.com
Thu Jan 5 12:48:55 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

Broken by:
   st/mesa: get Version from gl_program rather than gl_shader_program
---
 src/mesa/state_tracker/st_atom_texture.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index 58e753d..76e512f 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -116,25 +116,27 @@ update_textures(struct st_context *st,
    if (samplers_used == 0x0 && old_max == 0)
       return;
 
    *num_textures = 0;
 
    /* loop over sampler units (aka tex image units) */
    for (unit = 0; unit < max_units; unit++, samplers_used >>= 1) {
       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;
 
          *num_textures = unit + 1;
       }
       else if (samplers_used == 0 && unit >= old_max) {
          /* if we've reset all the old views and we have no more new ones */
          break;
       }
 
-- 
2.7.4



More information about the mesa-dev mailing list