Mesa (master): st/mesa: fix computing the lowest address for interleaved attribs
Marek Olšák
mareko at kemper.freedesktop.org
Wed Feb 23 14:21:22 UTC 2011
Module: Mesa
Branch: master
Commit: b65e2195c4a3aeb6179e2ec227ba0a2414efc8af
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b65e2195c4a3aeb6179e2ec227ba0a2414efc8af
Author: Wiktor Janas <wixorpeek at gmail.com>
Date: Wed Feb 23 07:10:12 2011 +0100
st/mesa: fix computing the lowest address for interleaved attribs
Ptr can be very well NULL, so when there are two arrays, with one having
offset 0 (and thus NULL Ptr), and the other having a non-zero offset,
the non-zero value is taken as minimum (because of !low_addr ? start ...).
On 32-bit systems, this somehow works. On 64-bit systems, it leads to crashes.
Signed-off-by: Marek Olšák <maraeo at gmail.com>
---
src/mesa/state_tracker/st_draw.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 11ebd06..6530a06 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -315,10 +315,13 @@ setup_interleaved_attribs(struct gl_context *ctx,
const GLubyte *low_addr = NULL;
/* Find the lowest address. */
- for (attr = 0; attr < vpv->num_inputs; attr++) {
- const GLubyte *start = arrays[vp->index_to_input[attr]]->Ptr;
+ if(vpv->num_inputs) {
+ low_addr = arrays[vp->index_to_input[0]]->Ptr;
- low_addr = !low_addr ? start : MIN2(low_addr, start);
+ for (attr = 1; attr < vpv->num_inputs; attr++) {
+ const GLubyte *start = arrays[vp->index_to_input[attr]]->Ptr;
+ low_addr = MIN2(low_addr, start);
+ }
}
for (attr = 0; attr < vpv->num_inputs; attr++) {
More information about the mesa-commit
mailing list