]> git.sesse.net Git - vlc/commitdiff
SaveConfigFile: correctly an error on I/O failure
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 24 Jul 2010 13:10:55 +0000 (16:10 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sat, 24 Jul 2010 13:12:18 +0000 (16:12 +0300)
src/config/file.c

index 0582483146ffd1bc15187956ef2cf5bfe28832f3..0d3f6b6afb06553ca3bea140be53db47127c36f3 100644 (file)
@@ -437,7 +437,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
     if( config_PrepareDir( p_this ) )
     {
         msg_Err( p_this, "no configuration directory" );
-        goto error;
+        return -1;
     }
 
     file = config_OpenConfigFile( p_this );
@@ -557,6 +557,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
     file = fdopen (fd, "wt");
     if (file == NULL)
     {
+        msg_Err (p_this, "cannot create configuration file: %m");
         vlc_rwlock_unlock (&config_lock);
         close (fd);
         vlc_mutex_unlock (&lock);
@@ -704,6 +705,14 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
      * Flush to disk and replace atomically
      */
     fflush (file); /* Flush from run-time */
+    if (ferror (file))
+    {
+        vlc_unlink (temporary);
+        vlc_mutex_unlock (&lock);
+        msg_Err (p_this, "cannot write configuration file");
+        clearerr (file);
+        goto error;
+    }
 #ifndef WIN32
 #ifdef __APPLE__
     fsync (fd); /* Flush from OS */