From: Sebastian Hammer Date: Wed, 7 Oct 2009 14:55:59 +0000 (+0200) Subject: Added check for no transform steps X-Git-Tag: v1.2.2~26 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=cdf7e43aa085ccd9ee8d8c9129bc1cdb0cc0c547;p=pazpar2-moved-to-github.git Added check for no transform steps --- diff --git a/src/normalize_record.c b/src/normalize_record.c index c33cd2e..322566e 100644 --- a/src/normalize_record.c +++ b/src/normalize_record.c @@ -124,30 +124,32 @@ int normalize_record_transform(normalize_record_t nt, xmlDoc **doc, const char **parms) { struct normalize_step *m; - for (m = nt->steps; m; m = m->next) - { - xmlNodePtr root = 0; - xmlDoc *new; - if (m->stylesheet) - { - new = xsltApplyStylesheet(m->stylesheet, *doc, parms); - } - else if (m->marcmap) - { - new = marcmap_apply(m->marcmap, *doc); - } - - root = xmlDocGetRootElement(new); - - if (!new || !root || !root->children) - { - if (new) - xmlFreeDoc(new); - xmlFreeDoc(*doc); - return -1; - } - xmlFreeDoc(*doc); - *doc = new; + if (nt) { + for (m = nt->steps; m; m = m->next) + { + xmlNodePtr root = 0; + xmlDoc *new; + if (m->stylesheet) + { + new = xsltApplyStylesheet(m->stylesheet, *doc, parms); + } + else if (m->marcmap) + { + new = marcmap_apply(m->marcmap, *doc); + } + + root = xmlDocGetRootElement(new); + + if (!new || !root || !root->children) + { + if (new) + xmlFreeDoc(new); + xmlFreeDoc(*doc); + return -1; + } + xmlFreeDoc(*doc); + *doc = new; + } } return 0; }