From ac6baa408e751313bdba2672d522b0ae7f38477d Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Fri, 30 Jun 2000 16:37:55 +0000 Subject: Add some checks for bad/nonexistant XML docs. svn path=/trunk/; revision=3828 --- filter/ChangeLog | 9 +++++++++ filter/filter-driver.c | 6 +++++- filter/filter-editor.c | 11 +++++++++-- filter/filter-xml.c | 4 ++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/filter/ChangeLog b/filter/ChangeLog index 6bcf2bd0a4..89dbfa465b 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,3 +1,12 @@ +2000-06-30 Peter Williams + + * filter-xml.c (filter_load_optionset_file): Check for failure + when loading the filter doc. + + * filter-driver.c (filter_driver_set_rules): Ditto. + + * filter-editor.c (filter_editor_set_rule_files): Ditto. + 2000-06-29 Ettore Perazzoli * filter-arg-types.c: Replaced `global_shell_interface' with diff --git a/filter/filter-driver.c b/filter/filter-driver.c index 92d337f958..357469ee3c 100644 --- a/filter/filter-driver.c +++ b/filter/filter-driver.c @@ -206,7 +206,11 @@ int filter_driver_set_rules(FilterDriver *d, const char *description, const char p->rules = filter_load_ruleset(desc); filt = xmlParseFile(filter); - p->options = filter_load_optionset(filt, p->rules); + if( filt == NULL ) { + g_warning( "Couldn't load filter file %s!", filter ); + p->options = NULL; + } else + p->options = filter_load_optionset(filt, p->rules); #warning "Zucchi: is this safe? Doesn't seem to cause problems..." filter_load_ruleset_free (p->rules); diff --git a/filter/filter-editor.c b/filter/filter-editor.c index bd039db21b..61ec13732c 100644 --- a/filter/filter-editor.c +++ b/filter/filter-editor.c @@ -370,8 +370,15 @@ filter_editor_set_rule_files(FilterEditor *e, const char *systemrules, const cha xmlDocPtr doc, out, optionset, filteroptions; doc = xmlParseFile(systemrules); - rules = filter_load_ruleset(doc); - options2 = filter_load_optionset(doc, rules); + if( doc == NULL ) { + g_warning( "Couldn't load system rules file %s", systemrules ); + rules = NULL; + options2 = NULL; + } else { + rules = filter_load_ruleset(doc); + options2 = filter_load_optionset(doc, rules); + } + out = xmlParseFile(userrules); if (out) options = filter_load_optionset(out, rules); diff --git a/filter/filter-xml.c b/filter/filter-xml.c index dc8271ae7e..ca95112127 100644 --- a/filter/filter-xml.c +++ b/filter/filter-xml.c @@ -555,6 +555,10 @@ GList *filter_load_optionset_file(const char *name, GList *rules) GList *options; doc = xmlParseFile(name); + if( doc == NULL ) { + g_warning( "Couldn't load option file %s!", name ); + return NULL; + } options = filter_load_optionset(doc, rules); xmlFreeDoc(doc); -- cgit