From fef7e1dffe2f9bb2ace71e90eb572e658f8b8fec Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sat, 9 Nov 2013 13:27:59 +0100 Subject: poll: Fix realloc in ssh_poll_ctx_resize(). --- src/poll.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/poll.c') diff --git a/src/poll.c b/src/poll.c index 8e21e0d5..2fce52a3 100644 --- a/src/poll.c +++ b/src/poll.c @@ -472,14 +472,18 @@ static int ssh_poll_ctx_resize(ssh_poll_ctx ctx, size_t new_size) { if (pollptrs == NULL) { return -1; } + ctx->pollptrs = pollptrs; pollfds = realloc(ctx->pollfds, sizeof(ssh_pollfd_t) * new_size); if (pollfds == NULL) { - ctx->pollptrs = realloc(pollptrs, sizeof(ssh_poll_handle) * ctx->polls_allocated); + pollptrs = realloc(ctx->pollptrs, sizeof(ssh_poll_handle) * ctx->polls_allocated); + if (pollptrs == NULL) { + return -1; + } + ctx->pollptrs = pollptrs; return -1; } - ctx->pollptrs = pollptrs; ctx->pollfds = pollfds; ctx->polls_allocated = new_size; -- cgit v1.2.1