From 090b1fdcac12ccf22376d9008836f9e2f4fc56a3 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 16 Jan 2007 18:44:25 +0000 Subject: [PATCH 1/1] Prevent NULL ptr reference in ingest_record by skipping NULL values of 'type' and 'data'. Fix small leak for 'type' and 'value' too. --- src/pazpar2.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/pazpar2.c b/src/pazpar2.c index 5dda86d..93be2e3 100644 --- a/src/pazpar2.c +++ b/src/pazpar2.c @@ -1,4 +1,4 @@ -/* $Id: pazpar2.c,v 1.36 2007-01-16 05:29:48 quinn Exp $ */ +/* $Id: pazpar2.c,v 1.37 2007-01-16 18:44:25 adam Exp $ */ #include #include @@ -491,8 +491,8 @@ static struct record *ingest_record(struct client *cl, Z_External *rec) struct record_cluster *cluster; struct session *se = cl->session; xmlChar *mergekey, *mergekey_norm; - xmlChar *type; - xmlChar *value; + xmlChar *type = 0; + xmlChar *value = 0; struct conf_service *service = global_parameters.server->service; if (!xdoc) @@ -525,7 +525,6 @@ static struct record *ingest_record(struct client *cl, Z_External *rec) } relevance_newrec(se->relevance, cluster); - type = value = 0; for (n = root->children; n; n = n->next) { if (type) @@ -546,6 +545,10 @@ static struct record *ingest_record(struct client *cl, Z_External *rec) type = xmlGetProp(n, "type"); value = xmlNodeListGetString(xdoc, n->children, 0); + + if (!type || !value) + continue; + // First, find out what field we're looking at for (imeta = 0; imeta < service->num_metadata; imeta++) if (!strcmp(type, service->metadata[imeta].name)) @@ -669,6 +672,10 @@ static struct record *ingest_record(struct client *cl, Z_External *rec) else yaz_log(YLOG_WARN, "Unexpected element %s in internal record", n->name); } + if (type) + xmlFree(type); + if (value) + xmlFree(value); xmlFreeDoc(xdoc); -- 1.7.10.4