diff --git a/i3bar/src/child.c b/i3bar/src/child.c index 97162cb4..a4c33bcd 100644 --- a/i3bar/src/child.c +++ b/i3bar/src/child.c @@ -61,12 +61,8 @@ void stdin_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) { } if (n == 0) { if (rec == buffer_len) { - char *tmp = buffer; - buffer = malloc(buffer_len + STDIN_CHUNK_SIZE); - memset(buffer, '\0', buffer_len); - strncpy(buffer, tmp, buffer_len); buffer_len += STDIN_CHUNK_SIZE; - FREE(tmp); + buffer = realloc(buffer, buffer_len); } else { /* remove trailing newline and finish up */ buffer[rec-1] = '\0';