Redo array element checking for vertex array buffers.
Now, compute ctx->Array._MaxElement as the min of enabled array's max element.
Test against ctx->Array._MaxElement in glDrawArrays/Elements.
Note: testing in glArrayElement not done yet.
Only do element checking if ctx->Const.CheckArrayBounds is set.
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 51abf86..f524045 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1062,6 +1062,15 @@
ctx->Const.MaxProgramMatrices = MAX_PROGRAM_MATRICES;
ctx->Const.MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH;
+ /* If we're running in the X server, do bounds checking to prevent
+ * segfaults and server crashes!
+ */
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ ctx->Const.CheckArrayBounds = GL_TRUE;
+#else
+ ctx->Const.CheckArrayBounds = GL_FALSE;
+#endif
+
ASSERT(ctx->Const.MaxTextureUnits == MAX2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits));
}