Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1376742

[PATCH] KEYS: fix memory leak

From Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] KEYS: fix memory leak
Date 2016-04-12 14:20 +0200
Message-ID <rn5st-7hl-15@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


If the file read fails then we returned NULL as error but we missed
freeing buf.

Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
---
 scripts/insert-sys-cert.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/insert-sys-cert.c b/scripts/insert-sys-cert.c
index 8902836..b98a0b1 100644
--- a/scripts/insert-sys-cert.c
+++ b/scripts/insert-sys-cert.c
@@ -251,6 +251,7 @@ static char *read_file(char *file_name, int *size)
 	if (read(fd, buf, *size) != *size) {
 		perror("File read failed");
 		close(fd);
+		free(buf);
 		return NULL;
 	}
 	close(fd);
-- 
1.9.1

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] KEYS: fix memory leak Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2016-04-12 14:20 +0200
  Re: [PATCH] KEYS: fix memory leak David Howells <dhowells@redhat.com> - 2016-04-12 20:10 +0200

csiph-web