From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MGyej-0005T1-5b for qemu-devel@nongnu.org; Wed, 17 Jun 2009 13:10:37 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MGyeY-0005H0-St for qemu-devel@nongnu.org; Wed, 17 Jun 2009 13:10:31 -0400 Received: from [199.232.76.173] (port=54842 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MGyeX-0005GQ-L9 for qemu-devel@nongnu.org; Wed, 17 Jun 2009 13:10:25 -0400 Received: from mx2.redhat.com ([66.187.237.31]:35971) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MGyeW-0007zZ-98 for qemu-devel@nongnu.org; Wed, 17 Jun 2009 13:10:24 -0400 From: Glauber Costa Date: Wed, 17 Jun 2009 13:09:55 -0400 Message-Id: <1245258604-2843-7-git-send-email-glommer@redhat.com> In-Reply-To: <1245258604-2843-6-git-send-email-glommer@redhat.com> References: <1245258604-2843-1-git-send-email-glommer@redhat.com> <1245258604-2843-2-git-send-email-glommer@redhat.com> <1245258604-2843-3-git-send-email-glommer@redhat.com> <1245258604-2843-4-git-send-email-glommer@redhat.com> <1245258604-2843-5-git-send-email-glommer@redhat.com> <1245258604-2843-6-git-send-email-glommer@redhat.com> Subject: [Qemu-devel] [PATCH 06/15] VNC: Fix memory allocation (wrong structure size). List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com From: Stefan Weil Pointer vs addresses a VncDisplay structure, so it is sufficient to allocate sizeof(VncDisplay) or sizeof(*vs) bytes instead of the much larger sizeof(VncState). Maybe the misleading name should be fixed, too: the code contains many places where vs is used, sometimes it is a VncState *, sometimes it is a VncDisplay *. vd would be a better name. Signed-off-by: Stefan Weil Signed-off-by: Anthony Liguori Signed-off-by: Glauber Costa --- vnc.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/vnc.c b/vnc.c index 783df80..1d8ebe7 100644 --- a/vnc.c +++ b/vnc.c @@ -2306,9 +2306,8 @@ static void vnc_listen_read(void *opaque) void vnc_display_init(DisplayState *ds) { - VncDisplay *vs; + VncDisplay *vs = qemu_mallocz(sizeof(*vs)); - vs = qemu_mallocz(sizeof(VncState)); dcl = qemu_mallocz(sizeof(DisplayChangeListener)); ds->opaque = vs; -- 1.6.2.2