Fix bug in CCL parser that could caused uninialized values
[yaz-moved-to-github.git] / src / seshigh.c
index c812921..dbc9af1 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: seshigh.c,v 1.49 2005-03-03 23:16:20 adam Exp $
+ * $Id: seshigh.c,v 1.52 2005-04-14 11:59:46 adam Exp $
  */
 /**
  * \file seshigh.c
@@ -916,6 +916,7 @@ static void srw_bend_search(association *assoc, request *req,
 
 static char *srw_bend_explain_default(void *handle, bend_explain_rr *rr)
 {
+#if HAVE_XML2
     xmlNodePtr ptr = rr->server_node_ptr;
     if (!ptr)
        return 0;
@@ -926,15 +927,16 @@ static char *srw_bend_explain_default(void *handle, bend_explain_rr *rr)
        if (!strcmp((const char *) ptr->name, "explain"))
        {
            int len;
-           ptr = xmlCopyNode(ptr, 1);
+           xmlDocPtr doc = xmlNewDoc("1.0");
+           xmlChar *buf_out;
+           char *content;
 
-           xmlDocPtr doc = xmlNewDoc((const xmlChar *) "1.0");
+           ptr = xmlCopyNode(ptr, 1);
         
            xmlDocSetRootElement(doc, ptr);
            
-           xmlChar *buf_out;
            xmlDocDumpMemory(doc, &buf_out, &len);
-           char *content = (char*) odr_malloc(rr->stream, 1+len);
+           content = (char*) odr_malloc(rr->stream, 1+len);
            memcpy(content, buf_out, len);
            content[len] = '\0';
            
@@ -944,6 +946,7 @@ static char *srw_bend_explain_default(void *handle, bend_explain_rr *rr)
            return 0;
        }
     }
+#endif
     return 0;
 }
 
@@ -1061,10 +1064,11 @@ static void srw_bend_scan(association *assoc, request *req,
        {
            if (assoc->cql_transform)
            {
+               int srw_error;
                bsrr->scanClause = 0;
                bsrr->attributeset = VAL_NONE;
                bsrr->term = odr_malloc(assoc->decode, sizeof(*bsrr->term));
-               int srw_error = cql2pqf_scan(assoc->encode,
+               srw_error = cql2pqf_scan(assoc->encode,
                                             srw_req->scanClause.cql,
                                             assoc->cql_transform,
                                             bsrr->term);
@@ -1756,7 +1760,7 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb)
                 assoc->init->implementation_name,
                 odr_prepend(assoc->encode, "GFS", resp->implementationName));
 
-    version = odr_strdup(assoc->encode, "$Revision: 1.49 $");
+    version = odr_strdup(assoc->encode, "$Revision: 1.52 $");
     if (strlen(version) > 10)   /* check for unexpanded CVS strings */
         version[strlen(version)-2] = '\0';
     resp->implementationVersion = odr_prepend(assoc->encode,
@@ -1962,10 +1966,10 @@ static Z_Records *pack_records(association *a, char *setname, int start,
         if (!(thisrec = (Z_NamePlusRecord *)
               odr_malloc(a->encode, sizeof(*thisrec))))
             return 0;
-        if (!(thisrec->databaseName = (char *)odr_malloc(a->encode,
-            strlen(freq.basename) + 1)))
-            return 0;
-        strcpy(thisrec->databaseName, freq.basename);
+       if (freq.basename)
+           thisrec->databaseName = odr_strdup(a->encode, freq.basename);
+       else
+           thisrec->databaseName = 0;
         thisrec->which = Z_NamePlusRecord_databaseRecord;
 
         if (freq.output_format_raw)