Commit afd3216027e3b28b0e180ac99d87e981d169b91c

Authored by Stefan Weil
Committed by Anthony Liguori
1 parent 91a073a9

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>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing 1 changed file with 1 additions and 2 deletions
... ... @@ -2033,9 +2033,8 @@ static void vnc_listen_read(void *opaque)
2033 2033  
2034 2034 void vnc_display_init(DisplayState *ds)
2035 2035 {
2036   - VncDisplay *vs;
  2036 + VncDisplay *vs = qemu_mallocz(sizeof(*vs));
2037 2037  
2038   - vs = qemu_mallocz(sizeof(VncState));
2039 2038 dcl = qemu_mallocz(sizeof(DisplayChangeListener));
2040 2039  
2041 2040 ds->opaque = vs;
... ...