We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent edb1c82 commit 39537e0Copy full SHA for 39537e0
bignum.c
@@ -5914,6 +5914,8 @@ bigsq(VALUE x)
5914
BDIGIT *xds, *zds;
5915
5916
xn = BIGNUM_LEN(x);
5917
+ if (MUL_OVERFLOW_LONG_P(2, xn))
5918
+ rb_raise(rb_eArgError, "square overflow");
5919
zn = 2 * xn;
5920
5921
z = bignew(zn, 1);
@@ -5942,6 +5944,8 @@ bigmul0(VALUE x, VALUE y)
5942
5944
5943
5945
5946
yn = BIGNUM_LEN(y);
5947
+ if (ADD_OVERFLOW_LONG_P(xn, yn))
5948
+ rb_raise(rb_eArgError, "multiplication overflow");
5949
zn = xn + yn;
5950
5951
z = bignew(zn, BIGNUM_SIGN(x)==BIGNUM_SIGN(y));
0 commit comments