summaryrefslogtreecommitdiff
path: root/channels.c
diff options
context:
space:
mode:
Diffstat (limited to 'channels.c')
-rw-r--r--channels.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/channels.c b/channels.c
index 1ff7152a8..0e7d5cf58 100644
--- a/channels.c
+++ b/channels.c
@@ -249,7 +249,7 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd,
249 /* Do initial allocation if this is the first call. */ 249 /* Do initial allocation if this is the first call. */
250 if (channels_alloc == 0) { 250 if (channels_alloc == 0) {
251 channels_alloc = 10; 251 channels_alloc = 10;
252 channels = xmalloc(channels_alloc * sizeof(Channel *)); 252 channels = xcalloc(channels_alloc, sizeof(Channel *));
253 for (i = 0; i < channels_alloc; i++) 253 for (i = 0; i < channels_alloc; i++)
254 channels[i] = NULL; 254 channels[i] = NULL;
255 } 255 }
@@ -274,8 +274,7 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd,
274 channels[i] = NULL; 274 channels[i] = NULL;
275 } 275 }
276 /* Initialize and return new channel. */ 276 /* Initialize and return new channel. */
277 c = channels[found] = xmalloc(sizeof(Channel)); 277 c = channels[found] = xcalloc(1, sizeof(Channel));
278 memset(c, 0, sizeof(Channel));
279 buffer_init(&c->input); 278 buffer_init(&c->input);
280 buffer_init(&c->output); 279 buffer_init(&c->output);
281 buffer_init(&c->extended); 280 buffer_init(&c->extended);
@@ -2842,7 +2841,7 @@ x11_create_display_inet(int x11_display_offset, int x11_use_localhost,
2842 } 2841 }
2843 2842
2844 /* Allocate a channel for each socket. */ 2843 /* Allocate a channel for each socket. */
2845 *chanids = xmalloc(sizeof(**chanids) * (num_socks + 1)); 2844 *chanids = xcalloc(num_socks + 1, sizeof(**chanids));
2846 for (n = 0; n < num_socks; n++) { 2845 for (n = 0; n < num_socks; n++) {
2847 sock = socks[n]; 2846 sock = socks[n];
2848 nc = channel_new("x11 listener", 2847 nc = channel_new("x11 listener",