Merge pull request #1754 from cesanta/iobuf_init

issue #1734, avoid passing null ptr to memmove
This commit is contained in:
Sergey Lyubka authored and GitHub committed 2022-09-24 07:18:42 +01:00
commit a5a9204f83
1 file changed
+1 -1
+1 -1
View File
@@ -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;