From f70a407611d11c7214b1f4a5b524148cc38c8a73 Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Fri, 23 Sep 2022 19:34:36 -0300 Subject: [PATCH] issue #1734, avoid passing null ptr to memmove --- src/iobuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iobuf.c b/src/iobuf.c index c0084b09..2ffaa912 100644 --- a/src/iobuf.c +++ b/src/iobuf.c @@ -28,7 +28,7 @@ int mg_iobuf_resize(struct mg_iobuf *io, size_t new_size) { void *p = calloc(1, new_size); if (p != NULL) { size_t len = new_size < io->len ? new_size : io->len; - if (len > 0) memmove(p, io->buf, len); + if (len > 0 && io->buf != NULL) memmove(p, io->buf, len); zeromem(io->buf, io->size); free(io->buf); io->buf = (unsigned char *) p;