diff --git a/src/loop.c b/src/loop.c index 46f15d24..0828c40c 100644 --- a/src/loop.c +++ b/src/loop.c @@ -539,7 +539,7 @@ static void loop_handle_reads_writes(struct mosquitto_db *db, struct pollfd *pol } }while(SSL_DATA_PENDING(context)); } - if(pollfds[context->pollfd_index].revents & (POLLERR | POLLNVAL | POLLHUP)){ + if(context->pollfd_index >= 0 && pollfds[context->pollfd_index].revents & (POLLERR | POLLNVAL | POLLHUP)){ do_disconnect(db, context); continue; }