All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Weil <Stefan.Weil@weilnetz.de>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [STABLE] [PATCH] VNC: Fix memory allocation (wrong structure size).
Date: Wed, 27 May 2009 21:23:10 +0200	[thread overview]
Message-ID: <4A1D931E.9010109@weilnetz.de> (raw)
In-Reply-To: <4A19AF1E.5030201@mail.berlios.de>

[-- Attachment #1: Type: text/plain, Size: 1047 bytes --]

Stefan Weil schrieb:
> 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 <weil@mail.berlios.de>
> ---
>  vnc.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/vnc.c b/vnc.c
> index 3f5d622..41defc2 100644
> --- a/vnc.c
> +++ b/vnc.c
> @@ -2033,9 +2033,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.5.6.5
>
>
>   

The patch above was whitespace broken.
The appended patch will work.

Regards,

Stefan Weil


[-- Attachment #2: 0003-VNC-Fix-memory-allocation-wrong-structure-size.patch --]
[-- Type: text/x-diff, Size: 1090 bytes --]

>From 1bcb958ac2127f96a8c3ee7fefa341f7296e48ba Mon Sep 17 00:00:00 2001
From: Stefan Weil <weil@mail.berlios.de>
Date: Sun, 24 May 2009 22:25:44 +0200
Subject: [PATCH] VNC: Fix memory allocation (wrong structure size).

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 <weil@mail.berlios.de>
---
 vnc.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/vnc.c b/vnc.c
index 3f5d622..41defc2 100644
--- a/vnc.c
+++ b/vnc.c
@@ -2033,9 +2033,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.5.6.5


      reply	other threads:[~2009-05-27 19:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-24 20:33 [Qemu-devel] [STABLE] [PATCH] VNC: Fix memory allocation (wrong structure size) Stefan Weil
2009-05-27 19:23 ` Stefan Weil [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A1D931E.9010109@weilnetz.de \
    --to=stefan.weil@weilnetz.de \
    --cc=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.