Merge pull request #385 from signalwire/apr_pool

[apr] Fix potential dereference of a null pointer when apr_pool_create_ex() is called without both an allocator and a parent while global_pool is uninitialized.
This commit is contained in:
Andrey Volk 2020-02-19 18:35:16 +04:00 committed by GitHub
commit b9a0b31ff4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -821,8 +821,17 @@ APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool,
if (!abort_fn && parent)
abort_fn = parent->abort_fn;
if (allocator == NULL)
if (allocator == NULL) {
if (!parent) {
/* There is no way to continue without an allocator when no parent */
if (abort_fn)
abort_fn(APR_EINVAL);
return APR_EINVAL;
}
allocator = parent->allocator;
}
if ((node = allocator_alloc(allocator,
MIN_ALLOC - APR_MEMNODE_T_SIZE)) == NULL) {