From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Uu7Gq-0004TU-3F for mharc-qemu-trivial@gnu.org; Tue, 02 Jul 2013 16:33:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uu7Gm-0004OS-9Y for qemu-trivial@nongnu.org; Tue, 02 Jul 2013 16:33:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uu7Gl-0000QW-5n for qemu-trivial@nongnu.org; Tue, 02 Jul 2013 16:33:48 -0400 Received: from v220110690675601.yourvserver.net ([78.47.199.172]:45994) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uu7Gf-0000Oq-4I; Tue, 02 Jul 2013 16:33:41 -0400 Received: from localhost (v220110690675601.yourvserver.net.local [127.0.0.1]) by v220110690675601.yourvserver.net (Postfix) with ESMTP id 2153F7281989; Tue, 2 Jul 2013 22:33:40 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at weilnetz.de Received: from v220110690675601.yourvserver.net ([127.0.0.1]) by localhost (v220110690675601.yourvserver.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P1ThR-l7VfUG; Tue, 2 Jul 2013 22:33:28 +0200 (CEST) Received: from [192.168.178.35] (p54ADBB03.dip0.t-ipconnect.de [84.173.187.3]) by v220110690675601.yourvserver.net (Postfix) with ESMTPSA id AD3507280102; Tue, 2 Jul 2013 22:33:28 +0200 (CEST) Message-ID: <51D33918.3030108@weilnetz.de> Date: Tue, 02 Jul 2013 22:33:28 +0200 From: Stefan Weil User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 MIME-Version: 1.0 To: qemu-trivial References: <1371382385-20415-1-git-send-email-sw@weilnetz.de> In-Reply-To: <1371382385-20415-1-git-send-email-sw@weilnetz.de> X-Enigmail-Version: 1.4.6 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 78.47.199.172 Cc: qemu-devel Subject: Re: [Qemu-trivial] [PATCH] savevm: Fix potential memory leak X-BeenThere: qemu-trivial@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jul 2013 20:33:49 -0000 Am 16.06.2013 13:33, schrieb Stefan Weil: > The leak was reported by cppcheck. Fix it by moving the g_malloc0 after > the argument validity check. > > Signed-off-by: Stefan Weil > --- > savevm.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/savevm.c b/savevm.c > index 2ce439f..b883714 100644 > --- a/savevm.c > +++ b/savevm.c > @@ -479,7 +479,7 @@ static const QEMUFileOps socket_write_ops = { > > QEMUFile *qemu_fopen_socket(int fd, const char *mode) > { > - QEMUFileSocket *s = g_malloc0(sizeof(QEMUFileSocket)); > + QEMUFileSocket *s; > > if (mode == NULL || > (mode[0] != 'r' && mode[0] != 'w') || > @@ -488,6 +488,7 @@ QEMUFile *qemu_fopen_socket(int fd, const char *mode) > return NULL; > } > > + s = g_malloc0(sizeof(QEMUFileSocket)); > s->fd = fd; > if (mode[0] == 'w') { > qemu_set_block(s->fd); Ping? From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uu7Gj-0004OL-Ra for qemu-devel@nongnu.org; Tue, 02 Jul 2013 16:33:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uu7Gf-0000PE-9g for qemu-devel@nongnu.org; Tue, 02 Jul 2013 16:33:45 -0400 Message-ID: <51D33918.3030108@weilnetz.de> Date: Tue, 02 Jul 2013 22:33:28 +0200 From: Stefan Weil MIME-Version: 1.0 References: <1371382385-20415-1-git-send-email-sw@weilnetz.de> In-Reply-To: <1371382385-20415-1-git-send-email-sw@weilnetz.de> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] savevm: Fix potential memory leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-trivial Cc: qemu-devel Am 16.06.2013 13:33, schrieb Stefan Weil: > The leak was reported by cppcheck. Fix it by moving the g_malloc0 after > the argument validity check. > > Signed-off-by: Stefan Weil > --- > savevm.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/savevm.c b/savevm.c > index 2ce439f..b883714 100644 > --- a/savevm.c > +++ b/savevm.c > @@ -479,7 +479,7 @@ static const QEMUFileOps socket_write_ops = { > > QEMUFile *qemu_fopen_socket(int fd, const char *mode) > { > - QEMUFileSocket *s = g_malloc0(sizeof(QEMUFileSocket)); > + QEMUFileSocket *s; > > if (mode == NULL || > (mode[0] != 'r' && mode[0] != 'w') || > @@ -488,6 +488,7 @@ QEMUFile *qemu_fopen_socket(int fd, const char *mode) > return NULL; > } > > + s = g_malloc0(sizeof(QEMUFileSocket)); > s->fd = fd; > if (mode[0] == 'w') { > qemu_set_block(s->fd); Ping?