shithub: mc

Download patch

ref: fb736dc5368eaa1b06d7e3c1d033deb1ba755fbb
parent: ae702f148386526a4043f675917ba4c2b3ac41b2
author: Ori Bernstein <[email protected]>
date: Sun Nov 30 16:04:53 EST 2014

Avoid division by zero deaths in the compiler.

    Print an error instead of dying.

--- a/mi/fold.c
+++ b/mi/fold.c
@@ -152,6 +152,9 @@
                 r = val(n->loc, a * b, exprtype(n));
             break;
         case Odiv:
+            /* x/0 = error */
+            if (isval(args[1], 0))
+                fatal(args[1], "division by zero");
             /* x/1 = x */
             if (isval(args[1], 1))
                 r = args[0];