gallium: fix trim() function bug when count < first
authorBrian Paul <brian.paul@tungstengraphics.com>
Fri, 4 Jul 2008 15:59:43 +0000 (09:59 -0600)
committerBrian Paul <brian.paul@tungstengraphics.com>
Fri, 4 Jul 2008 16:02:43 +0000 (10:02 -0600)
If the user called glDrawArrays(GL_TRIANGLES, count=1), trim() returned a
very large integer because of the unsigned arithmetic.

src/gallium/auxiliary/draw/draw_pt.c

index 9140faeea9d187d2a6fa7c88547a49ee86f59bc7..85a75525c8b752cfba92a2fe5e996edc206235fd 100644 (file)
@@ -37,6 +37,8 @@
 
 static unsigned trim( unsigned count, unsigned first, unsigned incr )
 {
+   if (count < first)
+      return 0;
    return count - (count - first) % incr; 
 }