fix for-loop in _mesa_GetDouble to avoid out of bounds memory read
[mesa.git] / src / mesa / main / light.c
index 44feeb507e9f594b0828a2ad0b514d8427e4d098..4c39d2ff4c97befd75b5670857ebc28a411f6667 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  5.1
+ * Version:  6.1
  *
- * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2004  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"),
@@ -409,14 +409,6 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params )
            return;
         FLUSH_VERTICES(ctx, _NEW_LIGHT);
         ctx->Light.Model.ColorControl = newenum;
-
-        if ((ctx->Light.Enabled &&
-             ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
-            || ctx->Fog.ColorSumEnabled)
-           ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
-        else
-           ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR;
-
          break;
       default:
          _mesa_error( ctx, GL_INVALID_ENUM, "glLightModel(pname=0x%x)", pname );
@@ -695,6 +687,8 @@ _mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params )
    GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* update materials */
 
+   FLUSH_CURRENT(ctx, 0); /* update ctx->Light.Material from vertex buffer */
+
    if (face==GL_FRONT) {
       f = 0;
    }
@@ -741,6 +735,8 @@ _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
    GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* update materials */
 
+   FLUSH_CURRENT(ctx, 0); /* update ctx->Light.Material from vertex buffer */
+
    if (face==GL_FRONT) {
       f = 0;
    }
@@ -880,7 +876,7 @@ _mesa_invalidate_shine_table( GLcontext *ctx, GLuint side )
    ASSERT(side < 2);
    if (ctx->_ShineTable[side])
       ctx->_ShineTable[side]->refcount--;
-   ctx->_ShineTable[side] = 0;
+   ctx->_ShineTable[side] = NULL;
 }
 
 
@@ -1133,6 +1129,7 @@ _mesa_update_tnl_spaces( GLcontext *ctx, GLuint new_state )
 {
    const GLuint oldneedeyecoords = ctx->_NeedEyeCoords;
 
+   (void) new_state;
    ctx->_NeedEyeCoords = 0;
 
    if (ctx->_ForceEyeCoords ||
@@ -1284,7 +1281,8 @@ _mesa_init_lighting( GLcontext *ctx )
    ctx->Light.ColorMaterialMode = GL_AMBIENT_AND_DIFFUSE;
    ctx->Light.ColorMaterialBitmask = _mesa_material_bitmask( ctx,
                                                GL_FRONT_AND_BACK,
-                                               GL_AMBIENT_AND_DIFFUSE, ~0, 0 );
+                                               GL_AMBIENT_AND_DIFFUSE, ~0,
+                                               NULL );
 
    ctx->Light.ColorMaterialEnabled = GL_FALSE;