diff options
author | Hans de Goede <hdegoede@redhat.com> | 2012-03-13 16:41:02 +0100 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2012-03-13 16:41:02 +0100 |
commit | 914e50814f151a9a5680018e2f264fd900885af9 (patch) | |
tree | 6c6bcdab33a0f215f37accce9cc5bebca0b0abb1 | |
parent | 42ac95e125286d3c9b012b33ef39e758f43dc083 (diff) | |
download | spice-914e50814f151a9a5680018e2f264fd900885af9.tar.gz spice-914e50814f151a9a5680018e2f264fd900885af9.tar.xz spice-914e50814f151a9a5680018e2f264fd900885af9.zip |
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@redhat.com>
-rw-r--r-- | server/red_worker.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/server/red_worker.c b/server/red_worker.c index f7c6ccbe..46d46f37 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. |