>From 17e727c1f822e8a15eaa882b2450d9d5163c09ad Mon Sep 17 00:00:00 2001 From: Jon Simons Date: Thu, 31 Oct 2013 08:32:15 +0100 Subject: [PATCH] poll: Fix memory leak in ssh_poll_ctx_free(). Call 'ssh_poll_free' to remove the poll handle from its context and free it. BUG: https://red.libssh.org/issues/128 Signed-off-by: Andreas Schneider --- src/poll.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/poll.c b/src/poll.c index bde0198..41b1bc7 100644 --- a/src/poll.c +++ b/src/poll.c @@ -448,9 +448,11 @@ ssh_poll_ctx ssh_poll_ctx_new(size_t chunk_size) { */ void ssh_poll_ctx_free(ssh_poll_ctx ctx) { if (ctx->polls_allocated > 0) { - while (ctx->polls_used > 0){ - ssh_poll_handle p = ctx->pollptrs[0]; - ssh_poll_ctx_remove(ctx, p); + size_t i; + + for (i = 0; i < ctx->polls_used; i++) { + ssh_poll_handle p = ctx->pollptrs[i]; + ssh_poll_free(p); } SAFE_FREE(ctx->pollptrs); -- 1.8.4