tnl: Don't dereference NULL obj pointer in replay_init

Structurally the code is now similar to the handling of other
gl_buffer_object::obj pointers elsewhere in TNL.  The fixes tag is a
little bit misleading.  I think the change in that commit just exposes a
previously existing bug.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2746
Fixes: f3cce7087a ("mesa: don't ever bind NullBufferObj for glBindBuffer targets")
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4512>
This commit is contained in:
Ian Romanick 2020-04-08 11:03:45 -07:00
parent 65f14fd68d
commit 2e43b32e72

View File

@ -476,14 +476,16 @@ replay_init(struct copy_context *copy)
* caller convert non-indexed prims to indexed. Could alternately
* do it internally.
*/
if (copy->ib->obj &&
!_mesa_bufferobj_mapped(copy->ib->obj, MAP_INTERNAL))
ctx->Driver.MapBufferRange(ctx, 0, copy->ib->obj->Size, GL_MAP_READ_BIT,
copy->ib->obj, MAP_INTERNAL);
if (copy->ib->obj) {
if (!_mesa_bufferobj_mapped(copy->ib->obj, MAP_INTERNAL))
ctx->Driver.MapBufferRange(ctx, 0, copy->ib->obj->Size, GL_MAP_READ_BIT,
copy->ib->obj, MAP_INTERNAL);
srcptr = (const GLubyte *)
ADD_POINTERS(copy->ib->obj->Mappings[MAP_INTERNAL].Pointer,
copy->ib->ptr);
srcptr = (const GLubyte *)
ADD_POINTERS(copy->ib->obj->Mappings[MAP_INTERNAL].Pointer,
copy->ib->ptr);
} else
srcptr = copy->ib->ptr;
switch (copy->ib->index_size_shift) {
case 0: