From c216c0a022ab832231757393d71b2d61ba646151 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 4 Jan 2007 07:38:36 +0000 Subject: [PATCH] Fixed NULL-ptr reference that occurred when type or value node becomes NULL in ingest_record. For NULL values omit call to add_facet and relevance_countwords. --- src/pazpar2.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/pazpar2.c b/src/pazpar2.c index 3482d83..1537054 100644 --- a/src/pazpar2.c +++ b/src/pazpar2.c @@ -1,4 +1,4 @@ -/* $Id: pazpar2.c,v 1.11 2007-01-04 07:27:29 adam Exp $ */; +/* $Id: pazpar2.c,v 1.12 2007-01-04 07:38:36 adam Exp $ */; #include #include @@ -455,21 +455,28 @@ static struct record *ingest_record(struct client *cl, Z_External *rec) { xmlChar *type = xmlGetProp(n, "type"); xmlChar *value = xmlNodeListGetString(xdoc, n->children, 0); - add_facet(se, type, value); - relevance_countwords(se->relevance, head, value, 1); + if (type && value) + { + add_facet(se, type, value); + relevance_countwords(se->relevance, head, value, 1); + } xmlFree(type); xmlFree(value); } else if (!strcmp(n->name, "metadata")) { xmlChar *type = xmlGetProp(n, "type"), *value; - if (!strcmp(type, "title")) - res->title = nmem_strdup(se->nmem, - value = xmlNodeListGetString(xdoc, n->children, 0)); - - relevance_countwords(se->relevance, head, value, 4); + if (type && !strcmp(type, "title")) + { + xmlChar *value = xmlNodeListGetString(xdoc, n->children, 0); + if (value) + { + res->title = nmem_strdup(se->nmem, value); + relevance_countwords(se->relevance, head, value, 4); + xmlFree(value); + } + } xmlFree(type); - xmlFree(value); } else yaz_log(YLOG_WARN, "Unexpected element %s in internal record", n->name); -- 1.7.10.4