]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix NULL pointer bug when using netdb and test_reachability.
authorwessels <>
Fri, 20 Apr 2007 02:21:34 +0000 (02:21 +0000)
committerwessels <>
Fri, 20 Apr 2007 02:21:34 +0000 (02:21 +0000)
The code in icp_v2.cc was not assigning ICP2state->request.  This only
caused a problem when the 'test_reachability' feature was in use.

I changed the contstructors for ICPState, ICP2State, and ICP3State
classes to accept an HttpRequest parameter.

src/ICP.h
src/icp_v2.cc
src/icp_v3.cc

index a7ebcd323e49dbecdb18c19f88ea1a604dcb3e85..58f1027f2f7026f6532548db4ba9bec815b36b18 100644 (file)
--- a/src/ICP.h
+++ b/src/ICP.h
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ICP.h,v 1.6 2003/08/10 11:00:40 robertc Exp $
+ * $Id: ICP.h,v 1.7 2007/04/19 20:21:34 wessels Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -77,7 +77,7 @@ class ICPState
 {
 
 public:
-    ICPState(icp_common_t &);
+    ICPState(icp_common_t &, HttpRequest *);
     virtual ~ ICPState();
     icp_common_t header;
     HttpRequest *request;
index 17ebf475094d6847ec82b0106a8e847510619cf5..b59285cca4c1e15c63fb6c50e29ee400f631b99f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: icp_v2.cc,v 1.95 2007/04/13 17:04:00 wessels Exp $
+ * $Id: icp_v2.cc,v 1.96 2007/04/19 20:21:34 wessels Exp $
  *
  * DEBUG: section 12    Internet Cache Protocol
  * AUTHOR: Duane Wessels
@@ -90,8 +90,9 @@ _icp_common_t::getOpCode() const
 
 /* ICPState */
 
-ICPState:: ICPState(icp_common_t & aHeader):header(aHeader)
-        ,request(NULL),
+ICPState:: ICPState(icp_common_t & aHeader, HttpRequest *aRequest):
+       header(aHeader),
+       request(HTTPMSGLOCK(aRequest)),
         fd(-1),
         url(NULL)
 {}
@@ -99,9 +100,7 @@ ICPState:: ICPState(icp_common_t & aHeader):header(aHeader)
 ICPState::~ICPState()
 {
     safe_free(url);
-
-    if (request)
-        delete request;
+    HTTPMSGUNLOCK(request);
 }
 
 
@@ -113,7 +112,8 @@ class ICP2State:public ICPState, public StoreClient
 {
 
 public:
-    ICP2State(icp_common_t & aHeader):ICPState(aHeader),rtt(0),src_rtt(0),flags(0)
+    ICP2State(icp_common_t & aHeader, HttpRequest *aRequest):
+       ICPState(aHeader, aRequest),rtt(0),src_rtt(0),flags(0)
     {}
 
     ~ICP2State();
@@ -473,7 +473,7 @@ doV2Query(int fd, struct sockaddr_in from, char *buf, icp_common_t header)
     }
 
     /* The peer is allowed to use this cache */
-    ICP2State *state = new ICP2State (header);
+    ICP2State *state = new ICP2State (header, icp_request);
 
     state->fd = fd;
 
index 6e6e790ce195fefb91e124c9ffd4980f26dc2b3d..2302f28d10defaf8653ff63c2285be43a2cba47c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: icp_v3.cc,v 1.40 2006/01/19 18:40:28 wessels Exp $
+ * $Id: icp_v3.cc,v 1.41 2007/04/19 20:21:34 wessels Exp $
  *
  * DEBUG: section 12    Internet Cache Protocol
  * AUTHOR: Duane Wessels
@@ -42,7 +42,9 @@ class ICP3State : public ICPState, public StoreClient
 {
 
 public:
-    ICP3State(icp_common_t &aHeader):ICPState(aHeader){}
+    ICP3State(icp_common_t &aHeader, HttpRequest *aRequest):
+       ICPState(aHeader, aRequest)
+       {}
 
     ~ICP3State();
     void created (StoreEntry *newEntry);
@@ -67,9 +69,7 @@ doV3Query(int fd, struct sockaddr_in from, char *buf, icp_common_t header)
     }
 
     /* The peer is allowed to use this cache */
-    ICP3State *state = new ICP3State (header);
-
-    state->request = icp_request;
+    ICP3State *state = new ICP3State (header, icp_request);
 
     state->fd = fd;