aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormilo <milo@r0ot.me>2011-04-20 04:09:28 +0200
committermilo <milo@r0ot.me>2011-05-02 17:39:28 +0200
commita03bb2fbf78c0c54325fb4591b098ef09abaa38a (patch)
treec90c0e8623a42e99d6b1b3dee4854ebf874e2c9f
parentbb784ec6be1b15c1895d4ec6fb31e35bc29dec81 (diff)
downloadlibssh-a03bb2fbf78c0c54325fb4591b098ef09abaa38a.tar.gz
libssh-a03bb2fbf78c0c54325fb4591b098ef09abaa38a.tar.xz
libssh-a03bb2fbf78c0c54325fb4591b098ef09abaa38a.zip
[poll] avoid infinite loop in ssh_poll_ctx_free()
(cherry picked from commit 809254160308289fdcddf8a5eabad0c85a35bce7)
-rw-r--r--src/poll.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/poll.c b/src/poll.c
index 87988608..bfcc4ad4 100644
--- a/src/poll.c
+++ b/src/poll.c
@@ -491,8 +491,13 @@ void ssh_poll_ctx_free(ssh_poll_ctx ctx) {
socket_t fd = ctx->pollfds[i].fd;
/* force poll object removal */
- if (p->cb(p, fd, POLLERR, p->cb_data) < 0) {
- used = ctx->polls_used;
+ if (p->cb && p->cb(p, fd, POLLERR, p->cb_data) < 0) {
+ if(ctx->polls_used < used) {
+ used = ctx->polls_used;
+ } else {
+ /* nothing to do */
+ i++;
+ }
} else {
i++;
}