From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:51403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPCFc-0002bC-Sw for qemu-devel@nongnu.org; Mon, 08 Apr 2013 09:36:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPCFW-0005p1-Io for qemu-devel@nongnu.org; Mon, 08 Apr 2013 09:36:48 -0400 Received: from mail-wi0-x229.google.com ([2a00:1450:400c:c05::229]:34177) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPCFW-0005oq-B2 for qemu-devel@nongnu.org; Mon, 08 Apr 2013 09:36:42 -0400 Received: by mail-wi0-f169.google.com with SMTP id c10so3828233wiw.0 for ; Mon, 08 Apr 2013 06:36:41 -0700 (PDT) Date: Mon, 8 Apr 2013 15:36:37 +0200 From: Stefan Hajnoczi Message-ID: <20130408133637.GC4429@stefanha-thinkpad.redhat.com> References: <1364903250-10429-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1364903250-10429-14-git-send-email-xiawenc@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1364903250-10429-14-git-send-email-xiawenc@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH V11 13/17] block: dump to buffer for bdrv_snapshot_dump() and bdrv_image_info_dump() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia Cc: kwolf@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, pbonzini@redhat.com On Tue, Apr 02, 2013 at 07:47:26PM +0800, Wenchao Xia wrote: > diff --git a/qemu-img.c b/qemu-img.c > index 5b229a9..032f68c 100644 > --- a/qemu-img.c > +++ b/qemu-img.c > @@ -1558,18 +1558,24 @@ static void dump_snapshots(BlockDriverState *bs) > { > QEMUSnapshotInfo *sn_tab, *sn; > int nb_sns, i; > - char buf[256]; > + GString *buf = g_string_new(NULL); > > nb_sns = bdrv_snapshot_list(bs, &sn_tab); > if (nb_sns <= 0) > return; Leaks buf. > diff --git a/savevm.c b/savevm.c > index e4e0008..ce0bbe1 100644 > --- a/savevm.c > +++ b/savevm.c > @@ -2466,7 +2466,7 @@ void do_info_snapshots(Monitor *mon, const QDict *qdict) > int nb_sns, i, ret, available; > int total; > int *available_snapshots; > - char buf[256]; > + GString *buf = NULL; > > bs = bdrv_snapshots(); > if (!bs) { > @@ -2509,11 +2509,16 @@ void do_info_snapshots(Monitor *mon, const QDict *qdict) > } > > if (total > 0) { Please declare buf here since it is only used in this scope.