Avoid crash if facet use attribute is not supplied
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 3 Aug 2010 10:59:03 +0000 (12:59 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 3 Aug 2010 10:59:03 +0000 (12:59 +0200)
ztest/ztest.c

index 7ddb3c6..2277398 100644 (file)
@@ -258,7 +258,7 @@ Z_OtherInformation *build_facet_response(ODR odr, Z_FacetList *facet_list) {
         yaz_log(YLOG_LOG, "Attributes: %s %d ", attrvalues.useattr, attrvalues.limit);
         if (attrvalues.errstring)
             yaz_log(YLOG_LOG, "Error parsing attributes: %s", attrvalues.errstring);
         yaz_log(YLOG_LOG, "Attributes: %s %d ", attrvalues.useattr, attrvalues.limit);
         if (attrvalues.errstring)
             yaz_log(YLOG_LOG, "Error parsing attributes: %s", attrvalues.errstring);
-        if (attrvalues.limit > 0) {
+        if (attrvalues.limit > 0 && attrvalues.useattr) {
             new_list->elements[new_index] = facet_field_create(odr, facet_list->elements[index]->attributes, attrvalues.limit);
             addterms(odr, new_list->elements[new_index], attrvalues.useattr);
             new_index++;
             new_list->elements[new_index] = facet_field_create(odr, facet_list->elements[index]->attributes, attrvalues.limit);
             addterms(odr, new_list->elements[new_index], attrvalues.useattr);
             new_index++;