From bfadaf1262452a3f84ab5d6ea8350235b0e99a2c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 2 May 2016 16:27:58 -0400 Subject: [PATCH] Fix: potential close() of uninitialized elf_fd MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit elf_fd is uninitialized whenever bin is NULL. Signed-off-by: Jérémie Galarneau --- lib/bin-info.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/bin-info.c b/lib/bin-info.c index 813c6830..e5d51500 100644 --- a/lib/bin-info.c +++ b/lib/bin-info.c @@ -482,7 +482,7 @@ end: static int bin_info_set_elf_file(struct bin_info *bin) { - int elf_fd; + int elf_fd = -1; Elf *elf_file = NULL; if (!bin) { @@ -512,7 +512,9 @@ int bin_info_set_elf_file(struct bin_info *bin) return 0; error: - close(elf_fd); + if (elf_fd >= 0) { + close(elf_fd); + } elf_end(elf_file); return -1; } -- 2.34.1