diff mbox

[for-1.4,06/12] qmp: Drop wasteful zero-initialization in qmp_memchar_read()

Message ID 1360081335-6594-7-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster Feb. 5, 2013, 4:22 p.m. UTC
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qemu-char.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Eric Blake Feb. 5, 2013, 10:10 p.m. UTC | #1
On 02/05/2013 09:22 AM, Markus Armbruster wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  qemu-char.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox

Patch

diff --git a/qemu-char.c b/qemu-char.c
index 036ca2c..0f91ca4 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2819,7 +2819,7 @@  char *qmp_memchar_read(const char *device, int64_t size,
 
     count = qemu_chr_cirmem_count(chr);
     size = size > count ? count : size;
-    read_data = g_malloc0(size + 1);
+    read_data = g_malloc(size + 1);
 
     cirmem_chr_read(chr, read_data, size);
 
@@ -2827,6 +2827,7 @@  char *qmp_memchar_read(const char *device, int64_t size,
         data = g_base64_encode(read_data, count);
         g_free(read_data);
     } else {
+        read_data[count] = 0;
         data = (char *)read_data;
     }