mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 12:35:05 +02:00
Check for 30-bit multiplication overflow
This commit is contained in:
parent
284dc05128
commit
b8f6db0290
1 changed files with 3 additions and 1 deletions
|
@ -2533,7 +2533,9 @@ static int Cyc_checked_sub(int x, int y, int *result)
|
||||||
static int Cyc_checked_mul(int x, int y, int *result)
|
static int Cyc_checked_mul(int x, int y, int *result)
|
||||||
{
|
{
|
||||||
*result = x * y;
|
*result = x * y;
|
||||||
return (*result != 0 && (*result)/x != y);
|
return (*result != 0 && (*result)/x != y) || // Overflow
|
||||||
|
(*result > CYC_FIXNUM_MAX) ||
|
||||||
|
(*result < CYC_FIXNUM_MIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define declare_num_op(FUNC, FUNC_OP, FUNC_APPLY, OP, INT_OP, BN_OP, NO_ARG, ONE_ARG, DIV) \
|
#define declare_num_op(FUNC, FUNC_OP, FUNC_APPLY, OP, INT_OP, BN_OP, NO_ARG, ONE_ARG, DIV) \
|
||||||
|
|
Loading…
Add table
Reference in a new issue