1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-02-04 07:33:07 +00:00

integer multiply overflow wasn't catching all cases (#100)

This commit is contained in:
Larry Masinter
2020-12-18 21:29:18 -08:00
committed by GitHub
parent d4f72d96e1
commit 761ab8cac6

View File

@@ -61,7 +61,7 @@ dummy:
#else
result = arg1 * arg2;
if ((arg2 != 0) && ((result / arg2) != arg1)) goto doufn2;
if ((arg2 != 0) && (((result % arg2) != 0) || ((result / arg2) != arg1))) goto doufn2;
N_ARITH_SWITCH(result);
#endif
@@ -91,7 +91,7 @@ dummy:
/* UB: signed integer overflow: 1073741824 * 32768 cannot be represented in type 'int' */
result = arg1 * arg2;
if ((arg2 != 0) && ((result / arg2) != arg1)) { goto doufn; }
if ((arg2 != 0) && (((result % arg2) != 0) || ((result / arg2) != arg1))) { goto doufn; }
N_ARITH_SWITCH(result);
#endif