diff options
Diffstat (limited to 'common/ini')
-rw-r--r-- | common/ini/ini_config.c | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/common/ini/ini_config.c b/common/ini/ini_config.c index b9cd6eb0..7ed82b18 100644 --- a/common/ini/ini_config.c +++ b/common/ini/ini_config.c @@ -219,19 +219,24 @@ static int ini_to_collection(FILE *file, break; case RET_ERROR: - pe.line = line; - pe.error = ext_err; - error = col_add_binary_property(*error_list, NULL, - ERROR_TXT, &pe, sizeof(pe)); - if (error) { - TRACE_ERROR_NUMBER("Failed to add error to collection", error); - col_destroy_collection(current_section); - if (created) { - col_destroy_collection(*error_list); - *error_list = NULL; + /* Try to add to the error list only if it is present */ + if (error_list) { + pe.line = line; + pe.error = ext_err; + error = col_add_binary_property(*error_list, NULL, + ERROR_TXT, &pe, sizeof(pe)); + if (error) { + TRACE_ERROR_NUMBER("Failed to add error to collection", + error); + col_destroy_collection(current_section); + if (created) { + col_destroy_collection(*error_list); + *error_list = NULL; + } + return error; } - return error; } + /* Exit if there was an error parsing file */ if (error_level != INI_STOP_ON_NONE) { TRACE_ERROR_STRING("Invalid format of the file", ""); @@ -242,19 +247,24 @@ static int ini_to_collection(FILE *file, case RET_INVALID: default: - pe.line = line; - pe.error = ext_err; - error = col_add_binary_property(*error_list, NULL, - WARNING_TXT, &pe, sizeof(pe)); - if (error) { - TRACE_ERROR_NUMBER("Failed to add warning to collection", error); - col_destroy_collection(current_section); - if (created) { - col_destroy_collection(*error_list); - *error_list = NULL; + /* Try to add to the error list only if it is present */ + if (error_list) { + pe.line = line; + pe.error = ext_err; + error = col_add_binary_property(*error_list, NULL, + WARNING_TXT, &pe, sizeof(pe)); + if (error) { + TRACE_ERROR_NUMBER("Failed to add warning to collection", + error); + col_destroy_collection(current_section); + if (created) { + col_destroy_collection(*error_list); + *error_list = NULL; + } + return error; } - return error; } + /* Exit if we are told to exit on warnings */ if (error_level == INI_STOP_ON_ANY) { TRACE_ERROR_STRING("Invalid format of the file", ""); |