We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 93c9c7c + 7477c1b commit 600da8cCopy full SHA for 600da8c
Zend/zend_strtod.c
@@ -3605,13 +3605,20 @@ rv_alloc(i) int i;
3605
rv_alloc(int i)
3606
#endif
3607
{
3608
- int k, *r;
3609
3610
- size_t j = sizeof(ULong);
+ int j, k, *r;
+ size_t rem;
3611
+
3612
+ rem = sizeof(Bigint) - sizeof(ULong) - sizeof(int);
3613
3614
3615
+ j = sizeof(ULong);
3616
+ if (i > ((INT_MAX >> 2) + rem))
3617
+ zend_error_noreturn(E_ERROR, "rv_alloc() allocation overflow %d", i);
3618
for(k = 0;
- sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= (size_t)i;
- j <<= 1)
3619
+ rem + j <= (size_t)i; j <<= 1)
3620
k++;
3621
3622
r = (int*)Balloc(k);
3623
*r = k;
3624
return
0 commit comments