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 <hdego...@redhat.com> --- server/red_worker.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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. -- 1.7.9.3 _______________________________________________ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel