From: Michael Stapelberg Date: Sun, 2 Sep 2012 22:41:15 +0000 (+0200) Subject: Bugfix: memleak: because we use i3string_from_utf8(), we need to free buffer() X-Git-Tag: 4.3~50 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2d1ebc2b90abda7f5af636babf3a33920a6963b3;p=i3%2Fi3 Bugfix: memleak: because we use i3string_from_utf8(), we need to free buffer() Previously, buffer was directly used and thus not freed, but i3string_from_utf8() makes a copy. --- diff --git a/i3bar/src/child.c b/i3bar/src/child.c index a5f49aa3..4f7a8707 100644 --- a/i3bar/src/child.c +++ b/i3bar/src/child.c @@ -217,7 +217,6 @@ void stdin_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) { fprintf(stderr, "[i3bar] Could not parse JSON input (code %d): %.*s\n", status, rec, json_input); } - free(buffer); } else { struct status_block *first = TAILQ_FIRST(&statusline_head); /* Clear the old buffer if any. */ @@ -229,6 +228,7 @@ void stdin_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) { else buffer[rec] = '\0'; first->full_text = i3string_from_utf8((const char *)buffer); } + free(buffer); draw_bars(); }