[vlc-commits] keystore/file: fix error path

Thomas Guillem git at videolan.org
Tue Apr 12 17:37:04 CEST 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Apr 12 17:33:07 2016 +0200| [1dfc6b132d9721f37143122e146acd393cdadd73] | committer: Thomas Guillem

keystore/file: fix error path

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1dfc6b132d9721f37143122e146acd393cdadd73
---

 modules/keystore/file.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/modules/keystore/file.c b/modules/keystore/file.c
index 3c7a75b..0c3f7bb 100644
--- a/modules/keystore/file.c
+++ b/modules/keystore/file.c
@@ -296,17 +296,22 @@ file_open(const char *psz_file, const char *psz_mode, FILE **pp_file)
 
     int i_fd = fileno(p_file);
     if (i_fd == -1)
+    {
+        fclose(p_file);
         return -1;
+    }
 
 #ifdef HAVE_FLOCK
     if (flock(i_fd, LOCK_EX) != 0)
     {
         fclose(p_file);
+        return -1;
     }
 #elif defined (HAVE_FCNTL) && defined (F_SETLKW)
     if (posix_lock_fd(i_fd) != 0)
     {
         fclose(p_file);
+        return -1;
     }
 #endif
     *pp_file = p_file;



More information about the vlc-commits mailing list