fix for-loop in _mesa_GetDouble to avoid out of bounds memory read
[mesa.git] / src / mesa / main / texstate.c
index a7369716b68731eef7267c10b4821ebb69309744..914518e4161ca39f894274da12b8390dc234d8c6 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.1
+ * Version:  6.3
  *
- * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -253,6 +253,8 @@ calculate_derived_texenv( struct gl_tex_env_combine_state *state,
         break;
       case GL_INTENSITY:
         mode_a = GL_INTERPOLATE;
+        state->SourceA[0] = GL_CONSTANT;
+        state->OperandA[2] = GL_SRC_ALPHA;
         /* FALLTHROUGH */
       case GL_LUMINANCE:
       case GL_RGB:
@@ -1386,7 +1388,9 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
               return;
            }
             FLUSH_VERTICES(ctx, _NEW_TEXTURE);
-            texObj->MaxAnisotropy = params[0];
+            /* clamp to max, that's what NVIDIA does */
+            texObj->MaxAnisotropy = MIN2(params[0],
+                                         ctx->Const.MaxTextureMaxAnisotropy);
          }
          else {
             _mesa_error(ctx, GL_INVALID_ENUM,
@@ -1964,7 +1968,7 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
       case GL_TEXTURE_LOD_BIAS:
          if (ctx->Extensions.EXT_texture_lod_bias) {
             *params = obj->LodBias;
-            break;
+            return;
          }
          break;
       default:
@@ -1993,12 +1997,6 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
    switch (pname) {
       case GL_TEXTURE_MAG_FILTER:
          *params = (GLint) obj->MagFilter;
-      case GL_TEXTURE_LOD_BIAS:
-         if (ctx->Extensions.EXT_texture_lod_bias) {
-            *params = (GLint) obj->LodBias;
-            break;
-         }
-         break;
          return;
       case GL_TEXTURE_MIN_FILTER:
          *params = (GLint) obj->MinFilter;
@@ -2098,6 +2096,12 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
             return;
          }
          break;
+      case GL_TEXTURE_LOD_BIAS:
+         if (ctx->Extensions.EXT_texture_lod_bias) {
+            *params = (GLint) obj->LodBias;
+            return;
+         }
+         break;
       default:
          ; /* silence warnings */
    }