mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-24 11:54:49 +00:00
Better check in mg_iobuf_resize()
This commit is contained in:
1 parent
05050eba38
commit
ab1c924388
1 file changed
+2
-1
+2
-1
@@ -14,7 +14,8 @@ int mg_iobuf_resize(struct mg_iobuf *io, size_t new_size) {
|
||||
// porting to some obscure platforms like FreeRTOS
|
||||
void *p = malloc(new_size);
|
||||
if (p != NULL) {
|
||||
memcpy(p, io->buf, io->size < new_size ? io->size : new_size);
|
||||
size_t len = new_size < io->len ? new_size : io->len;
|
||||
if (len > 0) memcpy(p, io->buf, len);
|
||||
free(io->buf);
|
||||
io->buf = (unsigned char *) p;
|
||||
io->size = new_size;
|
||||
|
||||
Reference in new issue
Block a user