Add overflow checks for unary minus.

This commit is contained in:
Dianne Skoll
2021-01-30 21:02:56 -05:00
parent 2123bf4b18
commit d667c15b25
3 changed files with 9 additions and 0 deletions

View File

@@ -1145,7 +1145,9 @@ static int UnMinus(void)
{
Value *v = &ValStack[ValStackPtr-1];
if (v->type != INT_TYPE) return E_BAD_TYPE;
int old = v->v.val;
v->v.val = -v->v.val;
if (_private_unminus_overflow(old, v->v.val)) return E_2HIGH;
return OK;
}