Skip to contentSkip to conversation

vnc_refresh: return if vd->timer is NULL

PATCH Applied Stefano Stabellini 2 participants 2 messages Jan 11, 2010 – Jan 12, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vnc_refresh: return if vd->timer is NULL

Hi all,
calling vnc_update_client in vnc_refresh might have the unlikely side effect of setting vd->timer = NULL, if the last vnc client disconnected. In this case we have to return from vnc_refresh without updating the timer, otherwise we cause a segfault.

---

vnc.c +4 -0
index c54c6e0..58eac73 100644
@@ -2305,6 +2305,10 @@ static void vnc_refresh(void *opaque)
         rects += vnc_update_client(vs, has_dirty);
         vs = vs->next;
     }
+    /* vd->timer could be NULL now if the last client disconnected,
+     * in this case don't update the timer */
+    if (vd->timer == NULL)
+        return;
 
     if (has_dirty && rects) {
         vd->timer_interval /= 2;
#1 lore raw
Quoted 8 lines · Stefano Stabellini

Hi all,
calling vnc_update_client in vnc_refresh might have the unlikely side effect of setting vd->timer = NULL, if the last vnc client disconnected. In this case we have to return from vnc_refresh without updating the timer, otherwise we cause a segfault.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 21 lines

---

vnc.c +4 -0
index c54c6e0..58eac73 100644
@@ -2305,6 +2305,10 @@ static void vnc_refresh(void *opaque)
          rects += vnc_update_client(vs, has_dirty);
          vs = vs->next;
      }
+    /* vd->timer could be NULL now if the last client disconnected,
+     * in this case don't update the timer */
+    if (vd->timer == NULL)
+        return;
 
      if (has_dirty&&  rects) {
          vd->timer_interval /= 2;