From: Tony Finch Date: Mon, 13 Jun 2022 11:00:01 +0000 (+0100) Subject: Improve DBC in isc_mem_free X-Git-Tag: v9.19.6~22^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a4930e196933f602e975028cfd8373d20381e60c;p=thirdparty%2Fbind9.git Improve DBC in isc_mem_free Unlike standard free(), isc_mem_free() is not a no-op when passed a NULL pointer. For size accounting purposes it calls sallocx(), which crashes when passed a NULL pointer. To get more helpful diagnostics, REQUIRE() that the pointer is not NULL so that when the programmer makes a mistake they get a backtrace that shows what went wrong. --- diff --git a/lib/isc/mem.c b/lib/isc/mem.c index 767f910c135..a68d7d67661 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -981,6 +981,7 @@ isc__mem_free(isc_mem_t *ctx, void *ptr FLARG) { size_t size = 0; REQUIRE(VALID_CONTEXT(ctx)); + REQUIRE(ptr != NULL); size = sallocx(ptr, 0);