aboutsummaryrefslogtreecommitdiff
path: root/qemu-char.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2013-02-06 21:27:18 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2013-02-06 16:35:18 -0600
commit13289fb5a716e06fb06febb880e5e116d485f82b (patch)
tree17ab54f0747aa12d2fe6243876110b5c890e59ae /qemu-char.c
parentc4f331b6b3b5fe260128f316ee9f01997f7c428d (diff)
qmp: Plug memory leaks in memchar-write, memchar-read
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qemu-char.c')
-rw-r--r--qemu-char.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/qemu-char.c b/qemu-char.c
index b1c613257b..4dd01e645a 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2782,6 +2782,10 @@ void qmp_memchar_write(const char *device, const char *data,
ret = cirmem_chr_write(chr, write_data, write_count);
+ if (write_data != (uint8_t *)data) {
+ g_free((void *)write_data);
+ }
+
if (ret < 0) {
error_setg(errp, "Failed to write to device %s", device);
return;
@@ -2825,6 +2829,7 @@ char *qmp_memchar_read(const char *device, int64_t size,
if (has_format && (format == DATA_FORMAT_BASE64)) {
data = g_base64_encode(read_data, size);
+ g_free(read_data);
} else {
data = (char *)read_data;
}