]> Savannah Git Hosting - gnulib.git/commitdiff
javacomp: Fix handle leak.
authorBruno Haible <bruno@clisp.org>
Tue, 16 May 2017 19:29:32 +0000 (21:29 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 16 May 2017 19:29:32 +0000 (21:29 +0200)
Found by Coverity.

* lib/javacomp.c (get_classfile_version): Close fd before returning.

ChangeLog
lib/javacomp.c

index 0fa2ac6ba0562b3ec6f6ff021ca4350674a15f32..932383e064b11ab8c631a6ef5ef4975a85737847 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-05-16  Bruno Haible  <bruno@clisp.org>
+
+       javacomp: Fix handle leak.
+       Found by Coverity.
+       * lib/javacomp.c (get_classfile_version): Close fd before returning.
+
 2017-05-16  Bruno Haible  <bruno@clisp.org>
 
        relocate: Make it easier to reclaim allocated memory.
index fe15b2c7328bf0363c5e30b5e45a52361f4ed368..3d7d457b2ec64c6760ba5dd6b144da815f5535dd 100644 (file)
@@ -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);
     }