[Spice-commits] server/red_worker.c

Hans de Goede jwrdegoede at kemper.freedesktop.org
Wed Mar 14 01:31:54 PDT 2012


 server/red_worker.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

New commits:
commit 914e50814f151a9a5680018e2f264fd900885af9
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Tue Mar 13 16:41:02 2012 +0100

    red_worker: Check for NULL watches
    
    If we run out of watches slots, we return NULL from watch_add, which
    means that the other watch_foo functions may get called with a NULL
    parameter, protect them against this.
    
    Signed-off-by: Hans de Goede <hdegoede at redhat.com>

diff --git a/server/red_worker.c b/server/red_worker.c
index f7c6ccb..46d46f3 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -9514,8 +9514,15 @@ static int common_channel_config_socket(RedChannelClient *rcc)
 
 static void worker_watch_update_mask(SpiceWatch *watch, int event_mask)
 {
-    struct RedWorker *worker = watch->worker;
-    int i = watch - worker->watches;
+    struct RedWorker *worker;
+    int i;
+
+    if (!watch) {
+        return;
+    }
+
+    worker = watch->worker;
+    i = watch - worker->watches;
 
     worker->poll_fds[i].events = 0;
     if (event_mask & SPICE_WATCH_EVENT_READ) {
@@ -9561,6 +9568,10 @@ static SpiceWatch *worker_watch_add(int fd, int event_mask, SpiceWatchFunc func,
 
 static void worker_watch_remove(SpiceWatch *watch)
 {
+    if (!watch) {
+        return;
+    }
+
     /* Note we don't touch the poll_fd here, to avoid the
        poll_fds/watches table entry getting re-used in the same
        red_worker_main loop over the fds as it is removed.


More information about the Spice-commits mailing list