Fix leak WRT server@id attr
[pazpar2-moved-to-github.git] / src / pazpar2_config.c
index 2ceda81..3b8a72e 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of Pazpar2.
-   Copyright (C) 2006-2009 Index Data
+   Copyright (C) 2006-2010 Index Data
 
 Pazpar2 is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
@@ -707,6 +707,7 @@ static struct conf_server *server_create(struct conf_config *config,
 {
     xmlNode *n;
     struct conf_server *server = nmem_malloc(nmem, sizeof(struct conf_server));
+    xmlChar *server_id = xmlGetProp(node, (xmlChar *) "id");
 
     server->host = 0;
     server->port = 0;
@@ -722,6 +723,13 @@ static struct conf_server *server_create(struct conf_config *config,
     server->mergekey_pct = 0;
     server->server_settings = 0;
 
+    if (server_id)
+    {
+        server->server_id = nmem_strdup(nmem, (const char *)server_id);
+        xmlFree(server_id);
+    }
+    else
+        server->server_id = 0;
     for (n = node->children; n; n = n->next)
     {
         if (n->type != XML_ELEMENT_NODE)
@@ -795,8 +803,7 @@ static struct conf_server *server_create(struct conf_config *config,
                 }
                 else if (!(*sp)->id && !service_id)
                 {
-                    yaz_log(YLOG_FATAL, "Duplicate unnamed service '%s'",
-                        service_id);
+                    yaz_log(YLOG_FATAL, "Duplicate unnamed service");
                     break;
                 }