From: Sami Kerola Date: Sun, 13 Mar 2016 10:31:40 +0000 (+0000) Subject: logger: fix memory leak [ASAN and valgrind] X-Git-Tag: v2.28-rc2~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e5411f623216c7ca700d5d63b5c2ec62ccc22ba;p=thirdparty%2Futil-linux.git logger: fix memory leak [ASAN and valgrind] Signed-off-by: Sami Kerola --- diff --git a/misc-utils/logger.c b/misc-utils/logger.c index 7b88b17482..1ef12cdd8d 100644 --- a/misc-utils/logger.c +++ b/misc-utils/logger.c @@ -341,8 +341,10 @@ static int journald_entry(struct logger_ctl *ctl, FILE *fp) for (lines = 0; /* nothing */ ; lines++) { buf = NULL; sz = getline(&buf, &dummy, fp); - if (sz == -1) + if (sz == -1) { + free(buf); break; + } if (0 < sz && buf[sz - 1] == '\n') { sz--; buf[sz] = '\0';