Fixed bad memory ref in case of SRU diagnostics.
[yaz-moved-to-github.git] / src / zoom-c.c
index 89456b2..1a3cf7a 100644 (file)
@@ -1454,13 +1454,15 @@ static zoom_ret send_srw(ZOOM_connection c, Z_SRW_PDU *sr)
 }
 #endif
 
-
-static Z_SRW_PDU *ZOOM_srw_get_pdu(ZOOM_connection c, int type) {
+#if YAZ_HAVE_XML2
+static Z_SRW_PDU *ZOOM_srw_get_pdu(ZOOM_connection c, int type)
+{
     Z_SRW_PDU *sr = yaz_srw_get_pdu(c->odr_out, type, c->sru_version);
     sr->username = c->user;
     sr->password = c->password;
     return sr;
 }
+#endif
 
 #if YAZ_HAVE_XML2
 static zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c)
@@ -4042,13 +4044,13 @@ static zoom_ret handle_srw_response(ZOOM_connection c,
     if (*count < 0)
         *count = 0;
 
-    if (res->num_diagnostics > 0)
-        set_SRU_error(c, &res->diagnostics[0]);
     nmem = odr_extract_mem(c->odr_in);
     nmem_transfer(odr_getmem(resultset->odr), nmem);
     nmem_destroy(nmem);
     
-    if (*count > 0)
+    if (res->num_diagnostics > 0)
+        set_SRU_error(c, &res->diagnostics[0]);
+    else if (*count > 0)
         return ZOOM_connection_srw_send_search(c);
     return zoom_complete;
 }