aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2013-11-09 13:27:59 +0100
committerAndreas Schneider <asn@cryptomilk.org>2013-11-09 13:27:59 +0100
commitfef7e1dffe2f9bb2ace71e90eb572e658f8b8fec (patch)
tree5273aa3f0b7ec9e0ba92a820abc48b383d2b94c9 /src
parent6d7bbe63fe68dd2bbc17d488ccc59d40cb9d8ba5 (diff)
downloadlibssh-fef7e1dffe2f9bb2ace71e90eb572e658f8b8fec.tar.gz
libssh-fef7e1dffe2f9bb2ace71e90eb572e658f8b8fec.tar.xz
libssh-fef7e1dffe2f9bb2ace71e90eb572e658f8b8fec.zip
poll: Fix realloc in ssh_poll_ctx_resize().
Diffstat (limited to 'src')
-rw-r--r--src/poll.c8
1 files changed, 6 insertions, 2 deletions
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;