mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-28 07:28:13 +08:00
Fix #1480 - use memmove instead of memcpy in mg_iobuf_resize()
This commit is contained in:
parent
42ba1e4aed
commit
a284df01d1
@ -1995,7 +1995,7 @@ int mg_iobuf_resize(struct mg_iobuf *io, size_t new_size) {
|
|||||||
void *p = calloc(1, new_size);
|
void *p = calloc(1, new_size);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
size_t len = new_size < io->len ? new_size : io->len;
|
size_t len = new_size < io->len ? new_size : io->len;
|
||||||
if (len > 0) memcpy(p, io->buf, len);
|
if (len > 0) memmove(p, io->buf, len);
|
||||||
zeromem(io->buf, io->size);
|
zeromem(io->buf, io->size);
|
||||||
free(io->buf);
|
free(io->buf);
|
||||||
io->buf = (unsigned char *) p;
|
io->buf = (unsigned char *) p;
|
||||||
|
@ -24,7 +24,7 @@ int mg_iobuf_resize(struct mg_iobuf *io, size_t new_size) {
|
|||||||
void *p = calloc(1, new_size);
|
void *p = calloc(1, new_size);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
size_t len = new_size < io->len ? new_size : io->len;
|
size_t len = new_size < io->len ? new_size : io->len;
|
||||||
if (len > 0) memcpy(p, io->buf, len);
|
if (len > 0) memmove(p, io->buf, len);
|
||||||
zeromem(io->buf, io->size);
|
zeromem(io->buf, io->size);
|
||||||
free(io->buf);
|
free(io->buf);
|
||||||
io->buf = (unsigned char *) p;
|
io->buf = (unsigned char *) p;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user