]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
check memory context validity before mem_destory
authorColin Vidal <colin@isc.org>
Sat, 18 Oct 2025 15:44:27 +0000 (17:44 +0200)
committerColin Vidal <colin@isc.org>
Sun, 19 Oct 2025 07:05:09 +0000 (09:05 +0200)
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).

lib/isc/mem.c

index 11d93f3ed65bad628645810790c742fa667fbb87..7b391042d9c14968b0745380e5518db10a464201 100644 (file)
@@ -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);