From 75dda08f9fd7b2e80b9587dbf329bc262b3c8ba9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sun, 12 Jul 2009 20:54:08 +0300 Subject: [PATCH] config: Remove temporary file if replacement failed --- src/config/file.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/config/file.c b/src/config/file.c index 9b779ab1b4..10a483e1f0 100644 --- a/src/config/file.c +++ b/src/config/file.c @@ -680,7 +680,8 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name, #ifndef WIN32 fdatasync (fd); /* Flush from OS */ /* Atomically replace the file... */ - utf8_rename (temporary, permanent); + if (utf8_rename (temporary, permanent)) + utf8_unlink (temporary); /* (...then synchronize the directory, err, TODO...) */ /* ...and finally close the file */ vlc_mutex_unlock (&lock); @@ -689,7 +690,8 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name, #ifdef WIN32 /* Windows cannot remove open files nor overwrite existing ones */ utf8_unlink (permanent); - utf8_rename (temporary, permanent); + if (utf8_rename (temporary, permanent)) + utf8_unlink (temporary); vlc_mutex_unlock (&lock); #endif -- 2.39.2