yeahuh / rpms / qemu-kvm

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