From: Mark Andrews Date: Tue, 3 Jan 2023 03:28:11 +0000 (+1100) Subject: Do not pass NULL pointer to memmove - undefined behaviour X-Git-Tag: v9.19.9~52^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=096b280b1c5a19f2a613682f421543d665ed6c4c;p=thirdparty%2Fbind9.git Do not pass NULL pointer to memmove - undefined behaviour Check if 'old_base' is NULL and if so skip calling memmove. --- diff --git a/lib/isc/include/isc/buffer.h b/lib/isc/include/isc/buffer.h index d9cec44c6b0..4e73c9c7c57 100644 --- a/lib/isc/include/isc/buffer.h +++ b/lib/isc/include/isc/buffer.h @@ -1150,7 +1150,9 @@ isc_buffer_reserve(isc_buffer_t *restrict dbuf, const unsigned int size) { if (!dbuf->dynamic) { void *old_base = dbuf->base; dbuf->base = isc_mem_get(dbuf->mctx, len); - memmove(dbuf->base, old_base, dbuf->used); + if (old_base != NULL) { + memmove(dbuf->base, old_base, dbuf->used); + } dbuf->dynamic = true; } else { dbuf->base = isc_mem_reget(dbuf->mctx, dbuf->base, dbuf->length,