Discussion:
javacomp: fix handle leak
(too old to reply)
Bruno Haible
2017-05-16 19:31:35 UTC
Permalink
Raw Message
The first fallout of the recent Coverity scan:


2017-05-16 Bruno Haible <***@clisp.org>

javacomp: Fix handle leak.
Found by Coverity.
* lib/javacomp.c (get_classfile_version): Close fd before returning.

diff --git a/lib/javacomp.c b/lib/javacomp.c
index fe15b2c..3d7d457 100644
--- a/lib/javacomp.c
+++ b/lib/javacomp.c
@@ -525,7 +525,10 @@ get_classfile_version (const char *compiled_file_name)
/* Verify the class file signature. */
if (header[0] == 0xCA && header[1] == 0xFE
&& header[2] == 0xBA && header[3] == 0xBE)
- return header[7];
+ {
+ close (fd);
+ return header[7];
+ }
}
close (fd);
}

Loading...