logger: fix memory leak [ASAN and valgrind]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
1d01d13eda
commit
4e5411f623
|
@ -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';
|
||||
|
|
Loading…
Reference in New Issue