From: Ondřej Surý Date: Sun, 18 Nov 2018 08:19:38 +0000 (+0100) Subject: Memory allocations must be fatal even when default_memalloc is not used X-Git-Tag: v9.13.5~40^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1a8a3faed021114f349160c316252fa5d29d04f;p=thirdparty%2Fbind9.git Memory allocations must be fatal even when default_memalloc is not used --- diff --git a/lib/isc/mem.c b/lib/isc/mem.c index 613d4c4d480..9bee9702644 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -164,7 +164,6 @@ struct isc__mem { size_t debuglistcnt; #endif - unsigned int memalloc_failures; ISC_LINK(isc__mem_t) link; }; @@ -364,10 +363,7 @@ more_basic_blocks(isc__mem_t *ctx) { table_size = ctx->basic_table_size + TABLE_INCREMENT; table = (ctx->memalloc)(ctx->arg, table_size * sizeof(unsigned char *)); - if (table == NULL) { - ctx->memalloc_failures++; - return (false); - } + RUNTIME_CHECK(table != NULL); ctx->malloced += table_size * sizeof(unsigned char *); if (ctx->malloced > ctx->maxmalloced) ctx->maxmalloced = ctx->malloced; @@ -384,10 +380,7 @@ more_basic_blocks(isc__mem_t *ctx) { } tmp = (ctx->memalloc)(ctx->arg, NUM_BASIC_BLOCKS * ctx->mem_target); - if (tmp == NULL) { - ctx->memalloc_failures++; - return (false); - } + RUNTIME_CHECK(tmp != NULL); ctx->total += NUM_BASIC_BLOCKS * ctx->mem_target;; ctx->basic_table[ctx->basic_table_count] = tmp; ctx->basic_table_count++; @@ -490,10 +483,7 @@ mem_getunlocked(isc__mem_t *ctx, size_t size) { * memget() was called on something beyond our upper limit. */ ret = (ctx->memalloc)(ctx->arg, size); - if (ret == NULL) { - ctx->memalloc_failures++; - goto done; - } + RUNTIME_CHECK(ret != NULL); ctx->total += size; ctx->inuse += size; ctx->stats[ctx->max_size].gets++; @@ -616,8 +606,7 @@ mem_get(isc__mem_t *ctx, size_t size) { size += 1; #endif ret = (ctx->memalloc)(ctx->arg, size); - if (ret == NULL) - ctx->memalloc_failures++; + RUNTIME_CHECK(ret != NULL); if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0)) { if (ISC_LIKELY(ret != NULL)) @@ -847,8 +836,6 @@ isc_mem_createx(size_t init_max_size, size_t target_size, } #endif - ctx->memalloc_failures = 0; - LOCK(&contextslock); ISC_LIST_INITANDAPPEND(contexts, ctx, link); UNLOCK(&contextslock);