9ae3a8
From 59e3d6e0995b2db39e4d87436c600e2475a9b502 Mon Sep 17 00:00:00 2001
9ae3a8
Message-Id: <59e3d6e0995b2db39e4d87436c600e2475a9b502.1387382496.git.minovotn@redhat.com>
9ae3a8
In-Reply-To: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
9ae3a8
References: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
9ae3a8
From: Nigel Croxon <ncroxon@redhat.com>
9ae3a8
Date: Thu, 14 Nov 2013 22:52:38 +0100
9ae3a8
Subject: [PATCH 02/46] savevm: Fix potential memory leak
9ae3a8
9ae3a8
RH-Author: Nigel Croxon <ncroxon@redhat.com>
9ae3a8
Message-id: <1384469598-13137-3-git-send-email-ncroxon@redhat.com>
9ae3a8
Patchwork-id: 55690
9ae3a8
O-Subject: [RHEL7.0 PATCH 02/42] savevm: Fix potential memory leak
9ae3a8
Bugzilla: 1011720
9ae3a8
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
9ae3a8
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
9ae3a8
Bugzilla: 1011720
9ae3a8
https://bugzilla.redhat.com/show_bug.cgi?id=1011720
9ae3a8
9ae3a8
>From commit ID:
9ae3a8
commit 4f080057767a684aab60998659e18f98c5fbefc7
9ae3a8
Author: Stefan Weil <sw@weilnetz.de>
9ae3a8
Date:   Sun Jun 16 13:33:05 2013 +0200
9ae3a8
9ae3a8
    savevm: Fix potential memory leak
9ae3a8
9ae3a8
    The leak was reported by cppcheck. Fix it by moving the g_malloc0 after
9ae3a8
    the argument validity check.
9ae3a8
9ae3a8
    Signed-off-by: Stefan Weil <sw@weilnetz.de>
9ae3a8
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9ae3a8
---
9ae3a8
 savevm.c |    3 ++-
9ae3a8
 1 files changed, 2 insertions(+), 1 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Michal Novotny <minovotn@redhat.com>
9ae3a8
---
9ae3a8
 savevm.c | 3 ++-
9ae3a8
 1 file changed, 2 insertions(+), 1 deletion(-)
9ae3a8
9ae3a8
diff --git a/savevm.c b/savevm.c
9ae3a8
index 4d12d92..4d898af 100644
9ae3a8
--- a/savevm.c
9ae3a8
+++ b/savevm.c
9ae3a8
@@ -479,7 +479,7 @@ static const QEMUFileOps socket_write_ops = {
9ae3a8
 
9ae3a8
 QEMUFile *qemu_fopen_socket(int fd, const char *mode)
9ae3a8
 {
9ae3a8
-    QEMUFileSocket *s = g_malloc0(sizeof(QEMUFileSocket));
9ae3a8
+    QEMUFileSocket *s;
9ae3a8
 
9ae3a8
     if (mode == NULL ||
9ae3a8
         (mode[0] != 'r' && mode[0] != 'w') ||
9ae3a8
@@ -488,6 +488,7 @@ QEMUFile *qemu_fopen_socket(int fd, const char *mode)
9ae3a8
         return NULL;
9ae3a8
     }
9ae3a8
 
9ae3a8
+    s = g_malloc0(sizeof(QEMUFileSocket));
9ae3a8
     s->fd = fd;
9ae3a8
     if (mode[0] == 'w') {
9ae3a8
         qemu_set_block(s->fd);
9ae3a8
-- 
9ae3a8
1.7.11.7
9ae3a8