| 709 | |
| 710 | |
| 711 | static int constfolding (OpCode op, expdesc *e1, expdesc *e2) { |
| 712 | lua_Number r; |
| 713 | if (!isnumeral(e1) || !isnumeral(e2)) return 0; |
| 714 | if ((op == OP_DIV || op == OP_MOD) && e2->u.nval == 0) |
| 715 | return 0; /* do not attempt to divide by 0 */ |
| 716 | /* |
| 717 | * Patched: check for MIN_INT / -1 |
| 718 | */ |
| 719 | if (op == OP_DIV && e1->u.nval == INT64_MIN && e2->u.nval == -1) |
| 720 | return 0; |
| 721 | r = luaO_arith(op - OP_ADD + LUA_OPADD, e1->u.nval, e2->u.nval); |
| 722 | e1->u.nval = r; |
| 723 | return 1; |
| 724 | } |
| 725 | |
| 726 | |
| 727 | static void codearith (FuncState *fs, OpCode op, |
no test coverage detected