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 fce3d4f commit 21b9ab3Copy full SHA for 21b9ab3
Zend/zend_strtod.c
@@ -3613,13 +3613,22 @@ rv_alloc(i) int i;
3613
rv_alloc(int i)
3614
#endif
3615
{
3616
- int j, k, *r;
+
3617
+ int k, *r;
3618
+ size_t j, rem;
3619
3620
+ rem = sizeof(Bigint) - sizeof(ULong) - sizeof(int);
3621
3622
3623
j = sizeof(ULong);
3624
+ if (i > (INT_MAX - rem))
3625
+ zend_error_noreturn(E_ERROR, "rv_alloc() allocation overflow %d", i);
3626
for(k = 0;
- j <= (INT_MAX >> 1) && sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= (size_t)i;
- j <<= 1)
3627
+ j <= (INT_MAX >> 1) && rem + j <= (size_t)i; j <<= 1)
3628
k++;
3629
+ if (j > (INT_MAX >> 1))
3630
+ zend_error_noreturn(E_ERROR, "rv_alloc() computation overflow " ZEND_LONG_FMT, j);
3631
3632
r = (int*)Balloc(k);
3633
*r = k;
3634
return
0 commit comments