From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afYOy-0000RR-Cx for qemu-devel@nongnu.org; Mon, 14 Mar 2016 15:43:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1afYOv-000212-4J for qemu-devel@nongnu.org; Mon, 14 Mar 2016 15:43:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46600) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afYOu-00020y-V6 for qemu-devel@nongnu.org; Mon, 14 Mar 2016 15:43:37 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 7CE152F1473 for ; Mon, 14 Mar 2016 19:43:36 +0000 (UTC) Date: Mon, 14 Mar 2016 19:43:32 +0000 From: "Dr. David Alan Gilbert" Message-ID: <20160314194332.GA15150@work-vm> References: <1457714282-6981-1-git-send-email-berrange@redhat.com> <1457714282-6981-3-git-send-email-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1457714282-6981-3-git-send-email-berrange@redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 02/28] io: avoid double-free when closing QIOChannelBuffer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: Amit Shah , qemu-devel@nongnu.org, Juan Quintela * Daniel P. Berrange (berrange@redhat.com) wrote: > The QIOChannelBuffer's close implementation will free > the internal data buffer. It failed to reset the pointer > to NULL though, so when the object is later finalized > it will free it a second time with predictable crash. > > Signed-off-by: Daniel P. Berrange > --- > io/channel-buffer.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/io/channel-buffer.c b/io/channel-buffer.c > index 3e5117b..43d7959 100644 > --- a/io/channel-buffer.c > +++ b/io/channel-buffer.c > @@ -140,6 +140,7 @@ static int qio_channel_buffer_close(QIOChannel *ioc, > QIOChannelBuffer *bioc = QIO_CHANNEL_BUFFER(ioc); > > g_free(bioc->data); > + bioc->data = NULL; > bioc->capacity = bioc->usage = bioc->offset = 0; Would it be better to call qui_channel_buffer_finalize(bioc) here, and put the data = NULL in there? (You could split this out of the series since it could go in any time?) Dave > > return 0; > -- > 2.5.0 > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK