mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Handle gracefully OOM in mysqlnd_mempool_create and up the stack
This commit is contained in:
parent
44bcdeeb77
commit
6dff9e55be
3 changed files with 51 additions and 29 deletions
|
@ -156,13 +156,17 @@ mysqlnd_mempool_create(size_t arena_size TSRMLS_DC)
|
|||
/* We calloc, because we free(). We don't mnd_calloc() for a reason. */
|
||||
MYSQLND_MEMORY_POOL * ret = mnd_calloc(1, sizeof(MYSQLND_MEMORY_POOL));
|
||||
DBG_ENTER("mysqlnd_mempool_create");
|
||||
|
||||
ret->free_size = ret->arena_size = arena_size ? arena_size : 0;
|
||||
ret->refcount = 0;
|
||||
/* OOM ? */
|
||||
ret->arena = mnd_malloc(ret->arena_size);
|
||||
ret->get_chunk = mysqlnd_mempool_get_chunk;
|
||||
|
||||
if (ret) {
|
||||
ret->get_chunk = mysqlnd_mempool_get_chunk;
|
||||
ret->free_size = ret->arena_size = arena_size ? arena_size : 0;
|
||||
ret->refcount = 0;
|
||||
/* OOM ? */
|
||||
ret->arena = mnd_malloc(ret->arena_size);
|
||||
if (!ret->arena) {
|
||||
mysqlnd_mempool_destroy(ret TSRMLS_CC);
|
||||
ret = NULL;
|
||||
}
|
||||
}
|
||||
DBG_RETURN(ret);
|
||||
}
|
||||
/* }}} */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue