Fix null pointer reference - occurred ir query charset was defined
[yazproxy-moved-to-github.git] / src / yaz-proxy.cpp
index f096210..4c17618 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: yaz-proxy.cpp,v 1.37 2005-09-26 09:25:06 adam Exp $
+/* $Id: yaz-proxy.cpp,v 1.40 2005-11-29 09:17:37 adam Exp $
    Copyright (c) 1998-2005, Index Data.
 
 This file is part of the yaz-proxy.
@@ -1107,6 +1107,9 @@ int Yaz_Proxy::send_http_response(int code)
     m_bytes_sent += len;
     m_bw_stat.add_bytes(len);
     logtime();
+
+    recv_GDU_more(true);
+
     return r;
 }
 
@@ -1153,6 +1156,9 @@ int Yaz_Proxy::send_srw_response(Z_SRW_PDU *srw_pdu)
     m_bytes_sent += len;
     m_bw_stat.add_bytes(len);
     logtime();
+
+    recv_GDU_more(true);
+
     return r;
 }
 
@@ -1830,8 +1836,8 @@ void Yaz_Proxy::recv_GDU_more(bool normal)
 
 void Yaz_Proxy::recv_GDU_normal(GDU *gdu)
 {
-    Z_GDU *apdu = gdu->get();
-    gdu->extract_odr_to(odr_decode());
+    Z_GDU *apdu = 0;
+    gdu->move_away_gdu(odr_decode(), &apdu);
     delete gdu;
 
     if (apdu->which == Z_GDU_Z3950)
@@ -2013,9 +2019,10 @@ void Yaz_Proxy::handle_charset_lang_negotiation(Z_APDU *apdu)
                 {
                     ODR_MASK_SET(initResponse->options,
                                  Z_Options_negotiationModel);
-                    ODR_MASK_SET(m_initRequest_options,
-                                 Z_Options_negotiationModel);
-
+                    if (m_initRequest_options)
+                        ODR_MASK_SET(m_initRequest_options,
+                                     Z_Options_negotiationModel);
+                    
                     oi->which = Z_OtherInfo_externallyDefinedInfo;    
                     oi->information.externallyDefinedInfo =
                         yaz_set_response_charneg(
@@ -2453,6 +2460,7 @@ int Yaz_Proxy::file_access(Z_HTTP_Request *hreq)
     }
     int len;
     send_GDU(gdu, &len);
+    recv_GDU_more(true);
     return 1;
 }
         
@@ -2606,7 +2614,8 @@ void Yaz_Proxy::handle_incoming_HTTP(Z_HTTP_Request *hreq)
                     const char *pqf_msg;
                     size_t off;
                     int code = yaz_pqf_error (pqf_parser, &pqf_msg, &off);
-                    yaz_log(YLOG_LOG, "%*s^\n", off+4, "");
+                    int ioff = off;
+                    yaz_log(YLOG_LOG, "%*s^\n", ioff+4, "");
                     yaz_log(YLOG_LOG, "Bad PQF: %s (code %d)\n", pqf_msg, code);
                     
                     send_to_srw_client_error(10, 0);