]> git.proxmox.com Git - mirror_qemu.git/commitdiff
vnc_refresh: calling vnc_update_client might free vs
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>
Mon, 25 Jan 2010 12:54:57 +0000 (12:54 +0000)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 26 Jan 2010 23:08:02 +0000 (17:08 -0600)
Hi all,
this patch fixes another bug in vnc_refresh: calling vnc_update_client
might cause vs to be free()ed, in this case we cannot access vs->next
right after to examine the next item on the list.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
vnc.c

diff --git a/vnc.c b/vnc.c
index cc2a26e5c678aafe28a21119013ffb96cdca6b9f..92facdec592e8aaa1017b0d669b09a2f1cc0aa00 100644 (file)
--- a/vnc.c
+++ b/vnc.c
@@ -2345,7 +2345,7 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
 static void vnc_refresh(void *opaque)
 {
     VncDisplay *vd = opaque;
-    VncState *vs = NULL;
+    VncState *vs = NULL, *vn = NULL;
     int has_dirty = 0, rects = 0;
 
     vga_hw_update();
@@ -2354,8 +2354,10 @@ static void vnc_refresh(void *opaque)
 
     vs = vd->clients;
     while (vs != NULL) {
+        vn = vs->next;
         rects += vnc_update_client(vs, has_dirty);
-        vs = vs->next;
+        /* vs might be free()ed here */
+        vs = vn;
     }
     /* vd->timer could be NULL now if the last client disconnected,
      * in this case don't update the timer */