summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorEdward O'Callaghan <[email protected]>2015-12-09 20:07:57 +1100
committerMarek Olšák <[email protected]>2015-12-09 22:51:56 +0100
commitf32f80e19d2f772b29ab3f3346ca524be356989e (patch)
tree6df7050279f80eeea9c2f9d964d42d434a5e659e /src/gallium/auxiliary
parent63fe600c7a3f0f7070827dc0c9fb37d5e908cb59 (diff)
gallium/util: Make u_prims_for_vertices() safe
Let us avoid trapping in hardware from a SIGFPE and instead assert on a zero divisor. Hint: This can occur if a PIPE_PRIM_? is not handled in u_prim_vertex_count() that results in ' info ' not being initialized in the expected manner. Further, we also fix a possibly NULL pointer dereference from ' info ' being NULL from a u_prim_vertex_count() call. Signed-off-by: Edward O'Callaghan <[email protected]> Signed-off-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/util/u_prim.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_prim.h b/src/gallium/auxiliary/util/u_prim.h
index 366801545ed..a09c315cc0a 100644
--- a/src/gallium/auxiliary/util/u_prim.h
+++ b/src/gallium/auxiliary/util/u_prim.h
@@ -145,6 +145,9 @@ u_prims_for_vertices(unsigned prim, unsigned num)
{
const struct u_prim_vertex_count *info = u_prim_vertex_count(prim);
+ assert(info);
+ assert(info->incr != 0);
+
if (num < info->min)
return 0;