From: wessels <> Date: Fri, 20 Apr 2007 02:21:34 +0000 (+0000) Subject: Fix NULL pointer bug when using netdb and test_reachability. X-Git-Tag: SQUID_3_0_PRE6~70 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f72fb56b62bae0114ddf6369faf2e9e16faeee1c;p=thirdparty%2Fsquid.git Fix NULL pointer bug when using netdb and test_reachability. 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. --- diff --git a/src/ICP.h b/src/ICP.h index a7ebcd323e..58f1027f2f 100644 --- 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; diff --git a/src/icp_v2.cc b/src/icp_v2.cc index 17ebf47509..b59285cca4 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -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; diff --git a/src/icp_v3.cc b/src/icp_v3.cc index 6e6e790ce1..2302f28d10 100644 --- a/src/icp_v3.cc +++ b/src/icp_v3.cc @@ -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;