diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c index 6fb707d..9a06631 100644 --- a/src/core/wee-config-file.c +++ b/src/core/wee-config-file.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "weechat.h" @@ -1896,6 +1897,7 @@ config_file_write_internal (struct t_config_file *config_file, char *filename, *filename2; struct t_config_section *ptr_section; struct t_config_option *ptr_option; + struct stat st; if (!config_file) return WEECHAT_CONFIG_WRITE_ERROR; @@ -1985,6 +1987,12 @@ config_file_write_internal (struct t_config_file *config_file, fclose (config_file->file); config_file->file = NULL; + if (stat (filename2, &st) != 0) + goto error; + + if (st.st_size == 0) + goto error; + /* update file mode */ chmod (filename2, 0600);