Check for overflow in abs()

This commit is contained in:
Dianne Skoll
2021-02-02 17:04:14 -05:00
parent 90cac447e4
commit 80d01f7158

View File

@@ -866,12 +866,14 @@ static int FTime(func_info *info)
/***************************************************************/
static int FAbs(func_info *info)
{
int v;
volatile int v;
ASSERT_TYPE(0, INT_TYPE);
v = ARGV(0);
RetVal.type = INT_TYPE;
RETVAL = (v < 0) ? (-v) : v;
v = RETVAL;
if (v < 0) return E_2HIGH;
return OK;
}