From: Brian Paul Date: Fri, 4 Jul 2008 15:59:43 +0000 (-0600) Subject: gallium: fix trim() function bug when count < first X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ba9e6339028c36269cb50bb8535e415fa8e6e4c9;p=mesa.git gallium: fix trim() function bug when count < first If the user called glDrawArrays(GL_TRIANGLES, count=1), trim() returned a very large integer because of the unsigned arithmetic. --- diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c index 9140faeea9d..85a75525c8b 100644 --- a/src/gallium/auxiliary/draw/draw_pt.c +++ b/src/gallium/auxiliary/draw/draw_pt.c @@ -37,6 +37,8 @@ static unsigned trim( unsigned count, unsigned first, unsigned incr ) { + if (count < first) + return 0; return count - (count - first) % incr; }