Commit 322d1cb5 authored by Ondřej Surý's avatar Ondřej Surý
Browse files

Abort on allocation failure only if the memory functions are used internally in BIND 9

(cherry picked from commit c22241ae)
parent 0ad69866
......@@ -862,6 +862,17 @@ mem_putstats(isc__mem_t *ctx, void *ptr, size_t size) {
static void *
default_memalloc(void *arg, size_t size) {
UNUSED(arg);
if (size == 0U) {
size = 1;
}
return (malloc(size));
}
static void *
internal_memalloc(void *arg, size_t size) {
void *ptr;
UNUSED(arg);
......@@ -2735,7 +2746,7 @@ isc_mem_create(size_t init_max_size, size_t target_size, isc_mem_t **mctxp) {
if (isc_bind9)
return (isc_mem_createx2(init_max_size, target_size,
default_memalloc, default_memfree,
internal_memalloc, default_memfree,
NULL, mctxp, isc_mem_defaultflags));
LOCK(&createlock);
......@@ -2754,7 +2765,7 @@ isc_mem_create2(size_t init_max_size, size_t target_size, isc_mem_t **mctxp,
{
if (isc_bind9)
return (isc_mem_createx2(init_max_size, target_size,
default_memalloc, default_memfree,
internal_memalloc, default_memfree,
NULL, mctxp, flags));
return (isc_mem_createx2(init_max_size, target_size,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment