From: Colin Vidal Date: Sat, 18 Oct 2025 15:44:27 +0000 (+0200) Subject: check memory context validity before mem_destory X-Git-Tag: v9.21.15~57^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c50ace654d877f442cf26c2043936eb005d46889;p=thirdparty%2Fbind9.git check memory context validity before mem_destory Add a magic number check to ensure the memory context validity before destorying it. This check is needed now as it was done before implicitly when isc_mem_inuse was called, but isc_mem_inuse is now called later (to be able to dump the outstanding allocations). --- diff --git a/lib/isc/mem.c b/lib/isc/mem.c index 11d93f3ed65..7b391042d9c 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -547,6 +547,8 @@ mem_create(const char *name, isc_mem_t **ctxp, unsigned int debugging, static void mem_destroy(isc_mem_t *ctx) { + REQUIRE(VALID_CONTEXT(ctx)); + isc_refcount_destroy(&ctx->references); LOCK(&contextslock);