mesa: don't ever bind NullBufferObj for glBindBuffer targets
[mesa.git] / src / mesa / vbo / vbo_primitive_restart.c
index d43d22856ab39a6a916a981ff464506423e7f379..1349740249f513a47251a3c7d99e4b8129cfddc3 100644 (file)
@@ -29,7 +29,7 @@
  */
 
 #include "main/errors.h"
-#include "main/imports.h"
+#include "util/imports.h"
 #include "main/macros.h"
 #include "main/varray.h"
 
@@ -179,8 +179,8 @@ vbo_sw_primitive_restart(struct gl_context *ctx,
    GLuint sub_end_index;
    GLuint restart_index = _mesa_primitive_restart_index(ctx, 1 << ib->index_size_shift);
    struct _mesa_prim temp_prim;
-   GLboolean map_ib = ib->obj->Name && !ib->obj->Mappings[MAP_INTERNAL].Pointer;
-   void *ptr;
+   GLboolean map_ib = ib->obj && !ib->obj->Mappings[MAP_INTERNAL].Pointer;
+   const void *ptr;
 
    /* If there is an indirect buffer, map it and extract the draw params */
    if (indirect) {
@@ -224,7 +224,10 @@ vbo_sw_primitive_restart(struct gl_context *ctx,
                                  ib->obj, MAP_INTERNAL);
    }
 
-   ptr = ADD_POINTERS(ib->obj->Mappings[MAP_INTERNAL].Pointer, ib->ptr);
+   if (ib->obj)
+      ptr = ADD_POINTERS(ib->obj->Mappings[MAP_INTERNAL].Pointer, ib->ptr);
+   else
+      ptr = ib->ptr;
 
    sub_prims = find_sub_primitives(ptr, 1 << ib->index_size_shift,
                                    0, ib->count, restart_index,