codegen.c: avoid integer overflow.

This commit is contained in:
Yukihiro "Matz" Matsumoto
2021-09-05 09:25:44 +09:00
parent 28c4f2f683
commit 7552b9322a
+1
View File
@@ -1128,6 +1128,7 @@ gen_uniop(codegen_scope *s, mrb_sym sym, uint16_t dst)
/* unary plus does nothing */
}
else if (sym == MRB_OPSYM_2(s->mrb, minus)) {
if (n == MRB_INT_MIN) return FALSE;
n = -n;
}
else if (sym == MRB_OPSYM_2(s->mrb, neg)) {