aboutsummaryrefslogtreecommitdiff
path: root/src/poll.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2013-12-22 22:08:45 +0100
committerAndreas Schneider <asn@cryptomilk.org>2013-12-22 22:26:51 +0100
commit2068973ff3ba6444f57494d2586f9aced3a23643 (patch)
tree01b5bf46ba008b3caf47ab2d8f5e622ce276c438 /src/poll.c
parent6eea08a9effa577a0df49b2dbfc456ed0cbd6a6d (diff)
downloadlibssh-2068973ff3ba6444f57494d2586f9aced3a23643.tar.gz
libssh-2068973ff3ba6444f57494d2586f9aced3a23643.tar.xz
libssh-2068973ff3ba6444f57494d2586f9aced3a23643.zip
poll: Correctly free ssh_event_fd_wrapper.
This is allocated by ssh_event_add_fd.
Diffstat (limited to 'src/poll.c')
-rw-r--r--src/poll.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/poll.c b/src/poll.c
index 2fce52a3..4d92e3f3 100644
--- a/src/poll.c
+++ b/src/poll.c
@@ -852,12 +852,18 @@ int ssh_event_remove_fd(ssh_event event, socket_t fd) {
for (i = 0; i < used; i++) {
if(fd == event->ctx->pollfds[i].fd) {
ssh_poll_handle p = event->ctx->pollptrs[i];
- struct ssh_event_fd_wrapper *pw = p->cb_data;
+ if (p->cb == ssh_event_fd_wrapper_callback) {
+ struct ssh_event_fd_wrapper *pw = p->cb_data;
+ SAFE_FREE(pw);
+ }
- ssh_poll_ctx_remove(event->ctx, p);
- free(pw);
+ /*
+ * The free function calls ssh_poll_ctx_remove() and decrements
+ * event->ctx->polls_used.
+ */
ssh_poll_free(p);
rc = SSH_OK;
+
/* restart the loop */
used = event->ctx->polls_used;
i = 0;