mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-10 06:23:01 +03:00
poll: Ensure that the poll handle and ctx is zeroed.
This commit is contained in:
23
src/poll.c
23
src/poll.c
@@ -309,11 +309,17 @@ ssh_poll_handle ssh_poll_new(socket_t fd, short events, ssh_poll_callback cb,
|
||||
ssh_poll_handle p;
|
||||
|
||||
p = malloc(sizeof(struct ssh_poll_handle_struct));
|
||||
if (p != NULL) {
|
||||
p->ctx = NULL;
|
||||
if (p == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
ZERO_STRUCTP(p);
|
||||
|
||||
p->x.fd = fd;
|
||||
p->events = events;
|
||||
if (cb != NULL) {
|
||||
p->cb = cb;
|
||||
}
|
||||
if (userdata != NULL) {
|
||||
p->cb_data = userdata;
|
||||
}
|
||||
|
||||
@@ -453,17 +459,16 @@ ssh_poll_ctx ssh_poll_ctx_new(size_t chunk_size) {
|
||||
ssh_poll_ctx ctx;
|
||||
|
||||
ctx = malloc(sizeof(struct ssh_poll_ctx_struct));
|
||||
if (ctx != NULL) {
|
||||
if (!chunk_size) {
|
||||
if (ctx == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
ZERO_STRUCTP(ctx);
|
||||
|
||||
if (chunk_size == 0) {
|
||||
chunk_size = SSH_POLL_CTX_CHUNK;
|
||||
}
|
||||
|
||||
ctx->chunk_size = chunk_size;
|
||||
ctx->pollptrs = NULL;
|
||||
ctx->pollfds = NULL;
|
||||
ctx->polls_allocated = 0;
|
||||
ctx->polls_used = 0;
|
||||
}
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
Reference in New Issue
Block a user