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>
This commit is contained in:
Markus Armbruster 2013-02-06 21:27:18 +01:00 committed by Anthony Liguori
parent c4f331b6b3
commit 13289fb5a7
1 changed files with 5 additions and 0 deletions

View File

@ -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;
}