From: Adam Dickmeiss Date: Tue, 7 Oct 2014 17:15:31 +0000 (+0200) Subject: 0 ptr reference in handling Solr response with error YAZ-791 X-Git-Tag: v5.4.3~5 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=89e7ff7931bdc7775faaeaf2a3c96cdb53532c8d;p=yaz-moved-to-github.git 0 ptr reference in handling Solr response with error YAZ-791 yaz_solr_decode_response will always return non-NULL PDU if return value is 0 (success). --- diff --git a/src/solr.c b/src/solr.c index e41d680..1c11765 100644 --- a/src/solr.c +++ b/src/solr.c @@ -328,11 +328,11 @@ static int yaz_solr_decode_scan_result(ODR o, xmlNodePtr ptr, int yaz_solr_decode_response(ODR o, Z_HTTP_Response *hres, Z_SRW_PDU **pdup) { int ret = -1; + Z_SRW_PDU *pdu = 0; #if YAZ_HAVE_XML2 const char *content_buf = hres->content_buf; int content_len = hres->content_len; xmlDocPtr doc = xmlParseMemory(content_buf, content_len); - Z_SRW_PDU *pdu = 0; if (doc) { @@ -342,8 +342,7 @@ int yaz_solr_decode_response(ODR o, Z_HTTP_Response *hres, Z_SRW_PDU **pdup) xmlNodePtr root = xmlDocGetRootElement(doc); if (root && !strcmp((const char *) root->name, "response")) { - ret = 0; - for (ptr = root->children; ptr && !ret; ptr = ptr->next) + for (ptr = root->children; ptr; ptr = ptr->next) { if (ptr->type == XML_ELEMENT_NODE && !strcmp((const char *) ptr->name, "result")) @@ -377,9 +376,8 @@ int yaz_solr_decode_response(ODR o, Z_HTTP_Response *hres, Z_SRW_PDU **pdup) } xmlFreeDoc(doc); } - if (ret == 0) - *pdup = pdu; #endif + *pdup = pdu; return ret; }