tgsi: Prevent division by zero.
authorJosé Fonseca <jrfonseca@tungstengraphics.com>
Thu, 7 Aug 2008 08:13:11 +0000 (09:13 +0100)
committerJosé Fonseca <jrfonseca@tungstengraphics.com>
Tue, 12 Aug 2008 12:00:20 +0000 (13:00 +0100)
src/gallium/auxiliary/tgsi/tgsi_exec.c

index 8b430548bca8521bd7c5388bf568b5099e020437..b93f3d5222a5c6a0789ae075629eb901b2271b4e 100644 (file)
@@ -393,10 +393,18 @@ micro_div(
    const union tgsi_exec_channel *src0,
    const union tgsi_exec_channel *src1 )
 {
-   dst->f[0] = src0->f[0] / src1->f[0];
-   dst->f[1] = src0->f[1] / src1->f[1];
-   dst->f[2] = src0->f[2] / src1->f[2];
-   dst->f[3] = src0->f[3] / src1->f[3];
+   if (src1->f[0] != 0) {
+      dst->f[0] = src0->f[0] / src1->f[0];
+   }
+   if (src1->f[1] != 0) {
+      dst->f[1] = src0->f[1] / src1->f[1];
+   }
+   if (src1->f[2] != 0) {
+      dst->f[2] = src0->f[2] / src1->f[2];
+   }
+   if (src1->f[3] != 0) {
+      dst->f[3] = src0->f[3] / src1->f[3];
+   }
 }
 
 static void