mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
Added missing allocation checks
This commit is contained in:
parent
896abc5e34
commit
37da90248d
@ -459,12 +459,20 @@ static Bigint * Balloc(int k)
|
||||
int x;
|
||||
Bigint *rv;
|
||||
|
||||
if (k > Kmax) {
|
||||
zend_error(E_ERROR, "Balloc() allocation exceeds list boundary");
|
||||
}
|
||||
|
||||
_THREAD_PRIVATE_MUTEX_LOCK(dtoa_mutex);
|
||||
if ((rv = freelist[k])) {
|
||||
freelist[k] = rv->next;
|
||||
} else {
|
||||
x = 1 << k;
|
||||
rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(Long));
|
||||
if (!rv) {
|
||||
_THREAD_PRIVATE_MUTEX_UNLOCK(dtoa_mutex);
|
||||
zend_error(E_ERROR, "Balloc() failed to allocate memory");
|
||||
}
|
||||
rv->k = k;
|
||||
rv->maxwds = x;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user