summaryrefslogtreecommitdiff
path: root/src/mesa/tnl
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2020-04-08 11:12:19 -0700
committerIan Romanick <ian.d.romanick@intel.com>2020-04-13 10:26:43 -0700
commit7a03240b635cd67f345811b86b9faf106f862ec0 (patch)
treef46b7b504bed878bd63da666a10c22509ab92d14 /src/mesa/tnl
parent2e43b32e72b2adf7ce865f56cf2647b137a5342a (diff)
tnl: Don't dereference NULL obj pointer in t_rebase_prims
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: f3cce7087a5 ("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>
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r--src/mesa/tnl/t_rebase.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/mesa/tnl/t_rebase.c b/src/mesa/tnl/t_rebase.c
index 2d53d947d3d..dc64e81fbd2 100644
--- a/src/mesa/tnl/t_rebase.c
+++ b/src/mesa/tnl/t_rebase.c
@@ -151,16 +151,19 @@ void t_rebase_prims( struct gl_context *ctx,
} else if (ib) {
/* Unfortunately need to adjust each index individually.
*/
- GLboolean map_ib = ib->obj &&
- !ib->obj->Mappings[MAP_INTERNAL].Pointer;
- void *ptr;
-
- if (map_ib)
- ctx->Driver.MapBufferRange(ctx, 0, ib->obj->Size, GL_MAP_READ_BIT,
- ib->obj, MAP_INTERNAL);
-
-
- ptr = ADD_POINTERS(ib->obj->Mappings[MAP_INTERNAL].Pointer, ib->ptr);
+ bool map_ib = false;
+ const void *ptr;
+
+ if (ib->obj) {
+ if (!ib->obj->Mappings[MAP_INTERNAL].Pointer) {
+ ctx->Driver.MapBufferRange(ctx, 0, ib->obj->Size, GL_MAP_READ_BIT,
+ ib->obj, MAP_INTERNAL);
+ map_ib = true;
+ }
+
+ ptr = ADD_POINTERS(ib->obj->Mappings[MAP_INTERNAL].Pointer, ib->ptr);
+ } else
+ ptr = ib->ptr;
/* Some users might prefer it if we translated elements to
* GLuints here. Others wouldn't...