diff options
author | Dmitri Pal <dpal@redhat.com> | 2010-06-10 12:19:01 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-06-28 08:38:14 -0400 |
commit | fefab388e9122a3d61cebdddd9ef128347e3c864 (patch) | |
tree | e813b6907394314b4a4a11f85460b2df44649baf | |
parent | e76a1323da65eef62672ea10d7d0cc1892c984bf (diff) | |
download | ding-libs-fefab388e9122a3d61cebdddd9ef128347e3c864.tar.gz ding-libs-fefab388e9122a3d61cebdddd9ef128347e3c864.tar.xz ding-libs-fefab388e9122a3d61cebdddd9ef128347e3c864.zip |
Fixing NULL dereferencing in ini_config
Addressing ticket #504
Conflicts:
common/ini/ini_config.c
-rw-r--r-- | ini/ini_config.c | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/ini/ini_config.c b/ini/ini_config.c index b9cd6eb..7ed82b1 100644 --- a/ini/ini_config.c +++ b/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", ""); |