]> git.proxmox.com Git - mirror_qemu.git/blobdiff - io/channel-buffer.c
migration: check length directly to make sure the range is aligned
[mirror_qemu.git] / io / channel-buffer.c
index 0f7c5671fefa18f253ab9cd62a4b51ae3233879f..5402e0cced39522a05ecde7fa9c104a876aaf2a6 100644 (file)
@@ -21,6 +21,7 @@
 #include "qemu/osdep.h"
 #include "io/channel-buffer.h"
 #include "io/channel-watch.h"
+#include "qemu/module.h"
 #include "qemu/sockets.h"
 #include "trace.h"
 
@@ -32,7 +33,7 @@ qio_channel_buffer_new(size_t capacity)
     ioc = QIO_CHANNEL_BUFFER(object_new(TYPE_QIO_CHANNEL_BUFFER));
 
     if (capacity) {
-        ioc->data = g_new0(char, capacity);
+        ioc->data = g_new0(uint8_t, capacity);
         ioc->capacity = capacity;
     }
 
@@ -140,6 +141,7 @@ static int qio_channel_buffer_close(QIOChannel *ioc,
     QIOChannelBuffer *bioc = QIO_CHANNEL_BUFFER(ioc);
 
     g_free(bioc->data);
+    bioc->data = NULL;
     bioc->capacity = bioc->usage = bioc->offset = 0;
 
     return 0;