util/u_vbuf: correct map offset calculation for crazy offsets
authorIlia Mirkin <imirkin@alum.mit.edu>
Thu, 23 Jan 2014 02:30:07 +0000 (21:30 -0500)
committerMaarten Lankhorst <maarten.lankhorst@canonical.com>
Mon, 27 Jan 2014 15:40:42 +0000 (16:40 +0100)
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>
src/gallium/auxiliary/util/u_vbuf.c

index 52b360ed7aa7c5fd89432cc2b41e407fc68f63b4..0c9c349e00e63626ff5423da3559f065f9604503 100644 (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);