Added missing allocation checks

This commit is contained in:
Ilia Alshanetsky 2007-03-06 03:15:41 +00:00
parent 896abc5e34
commit 37da90248d

View File

@ -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;
}