Merge pull request #9194 from jdgleaver/config-file-check-existence

(config_file.c) Only attempt to load config file if it exists
This commit is contained in:
Twinaphex 2019-07-25 14:31:45 +02:00 committed by GitHub
commit 68fab95e61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -603,12 +603,15 @@ config_file_t *config_file_new_from_path_to_string(const char *path)
uint8_t *ret_buf = NULL;
config_file_t *conf = NULL;
if (filestream_read_file(path, (void**)&ret_buf, &length))
if (path_is_valid(path))
{
if (length >= 0)
conf = config_file_new_from_string((const char*)ret_buf, path);
if ((void*)ret_buf)
free((void*)ret_buf);
if (filestream_read_file(path, (void**)&ret_buf, &length))
{
if (length >= 0)
conf = config_file_new_from_string((const char*)ret_buf, path);
if ((void*)ret_buf)
free((void*)ret_buf);
}
}
return conf;