From 89e7ff7931bdc7775faaeaf2a3c96cdb53532c8d Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 7 Oct 2014 19:15:31 +0200 Subject: [PATCH] 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). --- src/solr.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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; } -- 1.7.10.4