conf: skip empty configuration files to avoid crashing

g_mapped_file_get_contents() returns NULL if the file is empty

Fixes: #671
This commit is contained in:
George Kiagiadakis 2024-06-02 15:17:06 +03:00
parent 65e4ae83b9
commit 5235c025fe

View file

@ -216,6 +216,11 @@ open_and_load_sections (WpConf * self, const gchar *path, GError ** error)
if (!file)
return FALSE;
if (!g_mapped_file_get_contents (file) || g_mapped_file_get_length (file) == 0) {
wp_notice_object (self, "Ignoring empty configuration file at '%s'", path);
return TRUE;
}
/* test if the file is a relic from 0.4 */
if (detect_old_conf_format (self, file)) {
g_set_error (error, WP_DOMAIN_LIBRARY, WP_LIBRARY_ERROR_INVALID_ARGUMENT,