From: Erwan Velu Date: Thu, 19 Feb 2015 12:04:08 +0000 (+0100) Subject: iolog: Don't leak memory if fread fails in iolog_file_inflate X-Git-Tag: fio-2.2.6~10 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=244484810a69a2371d938b2a10dc468a667dd029 iolog: Don't leak memory if fread fails in iolog_file_inflate If fread fails in iolog_file_inflate(), the current code was closing the file descriptor and return 1. But it was missing freeing the previously malloced buffer (buf). This patch does add a memory free of 'buf' before returning to avoid the memory leak. --- diff --git a/iolog.c b/iolog.c index b867583a..7448ecfc 100644 --- a/iolog.c +++ b/iolog.c @@ -876,10 +876,12 @@ int iolog_file_inflate(const char *file) if (ret < 0) { perror("fread"); fclose(f); + free(buf); return 1; } else if (ret != 1) { log_err("fio: short read on reading log\n"); fclose(f); + free(buf); return 1; }