Commit 17986729 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

parent 1543df6b
...@@ -846,6 +846,17 @@ mem_putstats(isc__mem_t *ctx, void *ptr, size_t size) { ...@@ -846,6 +846,17 @@ mem_putstats(isc__mem_t *ctx, void *ptr, size_t size) {
static void * static void *
default_memalloc(void *arg, size_t size) { 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; void *ptr;
UNUSED(arg); UNUSED(arg);
...@@ -2783,7 +2794,7 @@ isc_mem_create(size_t init_max_size, size_t target_size, isc_mem_t **mctxp) { ...@@ -2783,7 +2794,7 @@ isc_mem_create(size_t init_max_size, size_t target_size, isc_mem_t **mctxp) {
if (isc_bind9) if (isc_bind9)
return (isc_mem_createx2(init_max_size, target_size, return (isc_mem_createx2(init_max_size, target_size,
default_memalloc, default_memfree, internal_memalloc, default_memfree,
NULL, mctxp, isc_mem_defaultflags)); NULL, mctxp, isc_mem_defaultflags));
LOCK(&createlock); LOCK(&createlock);
...@@ -2802,7 +2813,7 @@ isc_mem_create2(size_t init_max_size, size_t target_size, isc_mem_t **mctxp, ...@@ -2802,7 +2813,7 @@ isc_mem_create2(size_t init_max_size, size_t target_size, isc_mem_t **mctxp,
{ {
if (isc_bind9) if (isc_bind9)
return (isc_mem_createx2(init_max_size, target_size, return (isc_mem_createx2(init_max_size, target_size,
default_memalloc, default_memfree, internal_memalloc, default_memfree,
NULL, mctxp, flags)); NULL, mctxp, flags));
return (isc_mem_createx2(init_max_size, target_size, 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