util/u_vbuf: correct map offset calculation for crazy offsets

When the min_index is very large (or very negative), the multipliation
can overflow 32 bits and result in an incorrect map pointer
modification.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Ilia Mirkin 2014-01-22 21:30:07 -05:00 committed by Maarten Lankhorst
parent 3de97ce920
commit 45b64e52f4
1 changed files with 1 additions and 1 deletions

View File

@ -370,7 +370,7 @@ u_vbuf_translate_buffers(struct u_vbuf *mgr, struct translate_key *key,
/* Subtract min_index so that indexing with the index buffer works. */
if (unroll_indices) {
map -= vb->stride * min_index;
map -= (ptrdiff_t)vb->stride * min_index;
}
tr->set_buffer(tr, i, map, vb->stride, ~0);