glx: Correct opcode typos in __indirect_glTexCoordPointer.
[mesa.git] / src / glx / indirect_vertex_array.c
index 1d26c5eb6a91399e98c6322c80e6fc735339e491..01fab3345a93afed6dfeea47b7b68b693dafea1e 100644 (file)
@@ -135,9 +135,6 @@ __glXFreeVertexArrayState(struct glx_context * gc)
  * struct glx_context::server_minor, and __GLXcontext::server_major have been
  * initialized.  These values are used to determine what vertex arrays are
  * supported.
- *
- * \bug
- * Return values from malloc are not properly tested.
  */
 void
 __glXInitVertexArrayState(struct glx_context * gc)
@@ -154,7 +151,11 @@ __glXInitVertexArrayState(struct glx_context * gc)
 
 
    arrays = calloc(1, sizeof(struct array_state_vector));
-   state->array_state = arrays;
+
+   if (arrays == NULL) {
+      __glXSetError(gc, GL_OUT_OF_MEMORY);
+      return;
+   }
 
    arrays->old_DrawArrays_possible = !state->NoDrawArraysProtocol;
    arrays->new_DrawArrays_possible = GL_FALSE;
@@ -204,6 +205,12 @@ __glXInitVertexArrayState(struct glx_context * gc)
    arrays->num_arrays = array_count;
    arrays->arrays = calloc(array_count, sizeof(struct array_state));
 
+   if (arrays->arrays == NULL) {
+      free(arrays);
+      __glXSetError(gc, GL_OUT_OF_MEMORY);
+      return;
+   }
+
    arrays->arrays[0].data_type = GL_FLOAT;
    arrays->arrays[0].count = 3;
    arrays->arrays[0].key = GL_NORMAL_ARRAY;
@@ -274,7 +281,7 @@ __glXInitVertexArrayState(struct glx_context * gc)
    i += vertex_program_attribs;
 
 
-   /* Vertex array *must* be last becuase of the way that
+   /* Vertex array *must* be last because of the way that
     * emit_DrawArrays_none works.
     */
 
@@ -289,6 +296,18 @@ __glXInitVertexArrayState(struct glx_context * gc)
    arrays->stack = malloc(sizeof(struct array_stack_state)
                           * arrays->num_arrays
                           * __GL_CLIENT_ATTRIB_STACK_DEPTH);
+
+   if (arrays->stack == NULL) {
+      free(arrays->arrays);
+      free(arrays);
+      __glXSetError(gc, GL_OUT_OF_MEMORY);
+      return;
+   }
+
+   /* Everything went ok so we put vertex array state in place
+    * in context.
+    */
+   state->array_state = arrays;
 }
 
 
@@ -1367,7 +1386,7 @@ __indirect_glTexCoordPointer(GLint size, GLenum type, GLsizei stride,
       X_GLrop_TexCoord4iv
    };
    static const uint16_t float_ops[5] = {
-      0, X_GLrop_TexCoord1dv, X_GLrop_TexCoord2fv, X_GLrop_TexCoord3fv,
+      0, X_GLrop_TexCoord1fv, X_GLrop_TexCoord2fv, X_GLrop_TexCoord3fv,
       X_GLrop_TexCoord4fv
    };
    static const uint16_t double_ops[5] = {
@@ -1384,7 +1403,7 @@ __indirect_glTexCoordPointer(GLint size, GLenum type, GLsizei stride,
       X_GLrop_MultiTexCoord3ivARB, X_GLrop_MultiTexCoord4ivARB
    };
    static const uint16_t mfloat_ops[5] = {
-      0, X_GLrop_MultiTexCoord1dvARB, X_GLrop_MultiTexCoord2fvARB,
+      0, X_GLrop_MultiTexCoord1fvARB, X_GLrop_MultiTexCoord2fvARB,
       X_GLrop_MultiTexCoord3fvARB, X_GLrop_MultiTexCoord4fvARB
    };
    static const uint16_t mdouble_ops[5] = {
@@ -1568,9 +1587,18 @@ __indirect_glVertexAttribPointer(GLuint index, GLint size,
                                     GLenum type, GLboolean normalized,
                                     GLsizei stride, const GLvoid * pointer)
 {
-   static const uint16_t short_ops[5] = { 0, 4189, 4190, 4191, 4192 };
-   static const uint16_t float_ops[5] = { 0, 4193, 4194, 4195, 4196 };
-   static const uint16_t double_ops[5] = { 0, 4197, 4198, 4199, 4200 };
+   static const uint16_t short_ops[5] = {
+        0, X_GLrop_VertexAttrib1svARB, X_GLrop_VertexAttrib2svARB,
+        X_GLrop_VertexAttrib3svARB, X_GLrop_VertexAttrib4svARB
+   };
+   static const uint16_t float_ops[5] = {
+        0, X_GLrop_VertexAttrib1fvARB, X_GLrop_VertexAttrib2fvARB,
+        X_GLrop_VertexAttrib3fvARB, X_GLrop_VertexAttrib4fvARB
+   };
+   static const uint16_t double_ops[5] = {
+        0, X_GLrop_VertexAttrib1dvARB, X_GLrop_VertexAttrib2dvARB,
+        X_GLrop_VertexAttrib3dvARB, X_GLrop_VertexAttrib4dvARB
+   };
 
    uint16_t opcode;
    struct glx_context *gc = __glXGetCurrentContext();