Fixed NULL ptr refernece that could occur if a client sets negotiation
[yazproxy-moved-to-github.git] / src / yaz-proxy.cpp
index 6aae564..45fe382 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: yaz-proxy.cpp,v 1.28 2005-05-30 20:09:21 adam Exp $
+/* $Id: yaz-proxy.cpp,v 1.31 2005-06-10 17:54:11 adam Exp $
    Copyright (c) 1998-2005, Index Data.
 
 This file is part of the yaz-proxy.
@@ -53,6 +53,8 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <yaz/charneg.h>
 #include "msg-thread.h"
 
+using namespace yazpp_1;
+
 class Auth_Msg : public IMsg_Thread {
 public:
     int m_ret;
@@ -143,11 +145,11 @@ static const char *gdu_name(Z_GDU *gdu)
     return "Unknown request/response";
 }
 
-Yaz_Proxy::Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable,
-                    IYazSocketObservable *the_socket_observable,
+Yaz_Proxy::Yaz_Proxy(IPDU_Observable *the_PDU_Observable,
+                    ISocketObservable *the_socket_observable,
                     Yaz_Proxy *parent) 
     :
-    Yaz_Z_Assoc(the_PDU_Observable), m_bw_stat(60), m_pdu_stat(60)
+    Z_Assoc(the_PDU_Observable), m_bw_stat(60), m_pdu_stat(60)
 {
     m_PDU_Observable = the_PDU_Observable;
     m_socket_observable = the_socket_observable;
@@ -336,8 +338,8 @@ Yaz_ProxyConfig *Yaz_Proxy::check_reconfigure()
     return cfg;
 }
 
-IYaz_PDU_Observer *Yaz_Proxy::sessionNotify(IYaz_PDU_Observable
-                                           *the_PDU_Observable, int fd)
+IPDU_Observer *Yaz_Proxy::sessionNotify(IPDU_Observable
+                                       *the_PDU_Observable, int fd)
 {
     check_reconfigure();
     Yaz_Proxy *new_proxy = new Yaz_Proxy(the_PDU_Observable,
@@ -2680,13 +2682,15 @@ void Yaz_Proxy::handle_init(Z_APDU *apdu)
        m_initRequest_maximumRecordSize = *apdu->u.initRequest->
            maximumRecordSize;
        *apdu->u.initRequest->maximumRecordSize = 1024*1024;
+
+       Z_CharSetandLanguageNegotiation *charSetandLangRecord =
+           yaz_get_charneg_record(*oi);
        
        // Save proposal charsets and langs.
        if (ODR_MASK_GET(apdu->u.initRequest->options,
-                        Z_Options_negotiationModel))
+                        Z_Options_negotiationModel) 
+           && charSetandLangRecord)
        {
-           Z_CharSetandLanguageNegotiation *charSetandLangRecord =
-               yaz_get_charneg_record(*oi);
            
            yaz_get_proposal_charneg(m_referenceId_mem,
                                     charSetandLangRecord,
@@ -2973,8 +2977,8 @@ void Yaz_ProxyClient::connectNotify()
        pre_init_client();
 }
 
-IYaz_PDU_Observer *Yaz_ProxyClient::sessionNotify(IYaz_PDU_Observable
-                                                 *the_PDU_Observable, int fd)
+IPDU_Observer *Yaz_ProxyClient::sessionNotify(IPDU_Observable
+                                             *the_PDU_Observable, int fd)
 {
     return new Yaz_ProxyClient(the_PDU_Observable, 0);
 }
@@ -3175,9 +3179,9 @@ void Yaz_ProxyClient::timeoutNotify()
     shutdown();
 }
 
-Yaz_ProxyClient::Yaz_ProxyClient(IYaz_PDU_Observable *the_PDU_Observable,
+Yaz_ProxyClient::Yaz_ProxyClient(IPDU_Observable *the_PDU_Observable,
                                 Yaz_Proxy *parent) :
-    Yaz_Z_Assoc (the_PDU_Observable)
+    Z_Assoc (the_PDU_Observable)
 {
     m_cookie = 0;
     m_next = 0;
@@ -3362,7 +3366,7 @@ void Yaz_Proxy::low_socket_open()
 
 int Yaz_Proxy::server(const char *addr)
 {
-    int r = Yaz_Z_Assoc::server(addr);
+    int r = Z_Assoc::server(addr);
     if (!r)
     {
        yaz_log(YLOG_LOG, "%sStarted proxy "