Commit 02cae569 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

SaveConfigFile: correctly an error on I/O failure

parent be235a08
...@@ -437,7 +437,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name, ...@@ -437,7 +437,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
if( config_PrepareDir( p_this ) ) if( config_PrepareDir( p_this ) )
{ {
msg_Err( p_this, "no configuration directory" ); msg_Err( p_this, "no configuration directory" );
goto error; return -1;
} }
file = config_OpenConfigFile( p_this ); file = config_OpenConfigFile( p_this );
...@@ -557,6 +557,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name, ...@@ -557,6 +557,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
file = fdopen (fd, "wt"); file = fdopen (fd, "wt");
if (file == NULL) if (file == NULL)
{ {
msg_Err (p_this, "cannot create configuration file: %m");
vlc_rwlock_unlock (&config_lock); vlc_rwlock_unlock (&config_lock);
close (fd); close (fd);
vlc_mutex_unlock (&lock); vlc_mutex_unlock (&lock);
...@@ -704,6 +705,14 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name, ...@@ -704,6 +705,14 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
* Flush to disk and replace atomically * Flush to disk and replace atomically
*/ */
fflush (file); /* Flush from run-time */ 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 #ifndef WIN32
#ifdef __APPLE__ #ifdef __APPLE__
fsync (fd); /* Flush from OS */ fsync (fd); /* Flush from OS */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment