/* {{{ mysqlnd_mempool_resize_chunk */
-static void
+static enum_func_status
mysqlnd_mempool_resize_chunk(MYSQLND_MEMORY_POOL_CHUNK * chunk, unsigned int size TSRMLS_DC)
{
DBG_ENTER("mysqlnd_mempool_resize_chunk");
if ((chunk->size + pool->free_size) < size) {
zend_uchar *new_ptr;
new_ptr = mnd_malloc(size);
+ if (!new_ptr) {
+ DBG_RETURN(FAIL);
+ }
memcpy(new_ptr, chunk->ptr, chunk->size);
chunk->ptr = new_ptr;
pool->free_size += chunk->size;
} else {
zend_uchar *new_ptr;
new_ptr = mnd_malloc(size);
+ if (!new_ptr) {
+ DBG_RETURN(FAIL);
+ }
memcpy(new_ptr, chunk->ptr, chunk->size);
chunk->ptr = new_ptr;
chunk->size = size;
} else {
chunk->ptr = mnd_realloc(chunk->ptr, size);
}
- DBG_VOID_RETURN;
+ DBG_RETURN(PASS);
}
/* }}} */
MYSQLND_MEMORY_POOL *pool;
zend_uchar *ptr;
unsigned int size;
- void (*resize_chunk)(MYSQLND_MEMORY_POOL_CHUNK * chunk, unsigned int size TSRMLS_DC);
+ enum_func_status (*resize_chunk)(MYSQLND_MEMORY_POOL_CHUNK * chunk, unsigned int size TSRMLS_DC);
void (*free_chunk)(MYSQLND_MEMORY_POOL_CHUNK * chunk, zend_bool cache_it TSRMLS_DC);
zend_bool from_pool;
};
We need a trailing \0 for the last string, in case of text-mode,
to be able to implement read-only variables.
*/
- (*buffer)->resize_chunk((*buffer), *data_size + 1 TSRMLS_CC);
+ if (FAIL == (*buffer)->resize_chunk((*buffer), *data_size + 1 TSRMLS_CC)) {
+ SET_OOM_ERROR(conn->error_info);
+ ret = FAIL;
+ break;
+ }
/* The position could have changed, recalculate */
p = (*buffer)->ptr + (*data_size - header.size);
}