diff options
author | Erik Faye-Lund <erik.faye-lund@collabora.com> | 2021-05-04 13:04:48 +0200 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-05-05 11:16:42 +0000 |
commit | a2d091694f8cf30f7f8a15d9c26712d4e56eaa6c (patch) | |
tree | a66a86a1c2bc73f08debe2127280a3a8fc9346e3 /src/gallium/auxiliary | |
parent | c05e48308b432f93785520f48fbddc813040b11d (diff) |
gallium/u_vbuf: avoid dereferencing NULL pointer
When I last time fixed this, I missed that continuing here would make us
leak pointers in the translate state, which is what made this avoid a
crash in the first place.
That's not great, we need to set *some* pointer in this case. The
obvious option would be NULL, but that means that the translate-code
also needs to support NULL-pointers here.
Instead, let's point to a small, static buffer that contains enough
zero-data for the largest possible vertex attribute. This avoids having
to add more NULL-checks.
Fixes: a8e8204b186 ("gallium/u_vbuf: support NULL-resources")
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7773>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/util/u_vbuf.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c index 69c22e39258..4d826abdfa9 100644 --- a/src/gallium/auxiliary/util/u_vbuf.c +++ b/src/gallium/auxiliary/util/u_vbuf.c @@ -437,8 +437,11 @@ u_vbuf_translate_buffers(struct u_vbuf *mgr, struct translate_key *key, unsigned size = vb->stride ? num_vertices * vb->stride : sizeof(double)*4; - if (!vb->buffer.resource) + if (!vb->buffer.resource) { + static uint64_t dummy_buf[4] = { 0 }; + tr->set_buffer(tr, i, dummy_buf, 0, 0); continue; + } if (offset + size > vb->buffer.resource->width0) { /* Don't try to map past end of buffer. This often happens when |