[Mesa-dev] Fix a crash in update_texture_state() when requesting a fallback for external texture target

Abdiel Janulgue abdiel.janulgue at linux.intel.com
Wed Oct 10 04:42:24 PDT 2012


I found a crash where updating the texture unit states ends up requesting a 
fallback texture for a  GL_TEXTURE_EXTERNAL_OES target and sets a null current 
texture object for the current unit.

This is a fix by supporting  TEXTURE_EXTERNAL_INDEX target in 
_mesa_get_fallback_texture() and making sure the texture unit is not really 
used should an invalid  fallback be returned.

Cheers,
-abdiel

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index e0494c9..7e2b6b5 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -771,6 +771,9 @@ _mesa_get_fallback_texture(struct gl_context *ctx, 
gl_texture_index tex)
          target = GL_TEXTURE_BUFFER;
          break;
       case TEXTURE_EXTERNAL_INDEX:
+         dims = 2;
+         target = GL_TEXTURE_EXTERNAL_OES;
+         break;
       default:
          /* no-op */
          return NULL;
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 8ca9092..009b077 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -600,6 +600,11 @@ update_texture_state( struct gl_context *ctx )
 
             texTarget = (gl_texture_index) (ffs(enabledTargets) - 1);
             texObj = _mesa_get_fallback_texture(ctx, texTarget);
+            
+            if (!texObj)
+               /* invalid fallback texture: make sure to disable texture unit 
*/
+               continue;
+            
             _mesa_reference_texobj(&texUnit->_Current, texObj);
             texUnit->_ReallyEnabled = 1 << texTarget;
          }



More information about the mesa-dev mailing list