From 6ce6949a64c320786c7ca458034681b43c2c20f0 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Tue, 17 May 2016 15:43:59 -0400 Subject: [PATCH] Fix: Only close valid fds in is_valid_debug_file MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fixes coverity #1354901 and #1354902 Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- lib/bin-info.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/bin-info.c b/lib/bin-info.c index 55808eb0..93bca2a8 100644 --- a/lib/bin-info.c +++ b/lib/bin-info.c @@ -329,12 +329,12 @@ int is_valid_debug_file(char *path, uint32_t crc) uint32_t _crc = 0; if (!path) { - goto end; + goto end_noclose; } fd = open(path, O_RDONLY); if (fd < 0) { - goto end; + goto end_noclose; } ret = crc32(fd, &_crc); @@ -347,6 +347,7 @@ int is_valid_debug_file(char *path, uint32_t crc) end: close(fd); +end_noclose: return ret; } -- 2.34.1