2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

Do not pass NULL pointer to memmove - undefined behaviour

Check if 'old_base' is NULL and if so skip calling memmove.
This commit is contained in:
Mark Andrews
2023-01-03 14:28:11 +11:00
parent b2d08c514d
commit 096b280b1c

View File

@@ -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,