[vlc-commits] addons: fstorage: close fd before renaming.

Francois Cartegnie git at videolan.org
Fri Feb 14 11:09:08 CET 2014


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Feb 14 11:07:08 2014 +0100| [e7847d8d52da8c8fb1e1a2c9fbfd9d1145f0cbdd] | committer: Francois Cartegnie

addons: fstorage: close fd before renaming.

win32 can't rename a still open fd

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

 modules/misc/addons/fsstorage.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/modules/misc/addons/fsstorage.c b/modules/misc/addons/fsstorage.c
index 040fcf5..fcc3df7 100644
--- a/modules/misc/addons/fsstorage.c
+++ b/modules/misc/addons/fsstorage.c
@@ -637,13 +637,21 @@ static int WriteCatalog( addons_storage_t *p_storage,
         vlc_mutex_unlock( &p_entry->lock );
     }
 
-    vlc_rename( psz_file_tmp, psz_file );
-    free( psz_file );
-    free( psz_file_tmp );
-
     fprintf( p_catalog, "\t</addons>\n" );
     fprintf( p_catalog, "</videolan>\n" );
     fclose( p_catalog );
+
+    int i_ret = vlc_rename( psz_file_tmp, psz_file );
+    free( psz_file );
+    free( psz_file_tmp );
+
+    if( i_ret == -1 )
+    {
+        msg_Err( p_storage, "could not rename %s: %s",
+                 psz_file_tmp, vlc_strerror_c(errno) );
+        return VLC_EGENERIC;
+    }
+
     return VLC_SUCCESS;
 }
 



More information about the vlc-commits mailing list