From 07b4cf01c2677de9b81d1d233217c08a371c8fd8 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Sun, 18 Jan 2015 00:11:50 -0800 Subject: [PATCH] Fix several crashes when debugging enabled psstate->entry may be null, it is not safe to directly access the entry url() method. Use the safe alternative offered by psstate instead. --- src/peer_select.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/peer_select.cc b/src/peer_select.cc index 9c26a20c57..db88efabc4 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -122,7 +122,7 @@ peerSelectIcpPing(HttpRequest * request, int direct, StoreEntry * entry) assert(entry); assert(entry->ping_status == PING_NONE); assert(direct != DIRECT_YES); - debugs(44, 3, "peerSelectIcpPing: " << entry->url() ); + debugs(44, 3, "peerSelectIcpPing: " << entry->url()); if (!request->flags.hierarchical && direct != DIRECT_NO) return 0; @@ -262,7 +262,7 @@ peerSelectDnsPaths(ps_state *psstate) if (fs && psstate->paths->size() < (unsigned int)Config.forward_max_tries) { // send the next one off for DNS lookup. const char *host = fs->_peer ? fs->_peer->host : psstate->request->GetHost(); - debugs(44, 2, "Find IP destination for: " << psstate->entry->url() << "' via " << host); + debugs(44, 2, "Find IP destination for: " << psstate->url() << "' via " << host); ipcache_nbgethostbyname(host, peerSelectDnsResults, psstate); return; } @@ -744,7 +744,7 @@ peerPingTimeout(void *data) StoreEntry *entry = psstate->entry; if (entry) - debugs(44, 3, "peerPingTimeout: '" << entry->url() << "'" ); + debugs(44, 3, "peerPingTimeout: '" << psstate->url() << "'" ); if (!cbdataReferenceValid(psstate->callback_data)) { /* request aborted */ @@ -812,7 +812,7 @@ peerHandleIcpReply(CachePeer * p, peer_t type, icp_common_t * header, void *data { ps_state *psstate = (ps_state *)data; icp_opcode op = header->getOpCode(); - debugs(44, 3, "peerHandleIcpReply: " << icp_opcode_str[op] << " " << psstate->entry->url() ); + debugs(44, 3, "peerHandleIcpReply: " << icp_opcode_str[op] << " " << psstate->url() ); #if USE_CACHE_DIGESTS && 0 /* do cd lookup to count false misses */ @@ -845,9 +845,7 @@ static void peerHandleHtcpReply(CachePeer * p, peer_t type, HtcpReplyData * htcp, void *data) { ps_state *psstate = (ps_state *)data; - debugs(44, 3, "peerHandleHtcpReply: " << - (htcp->hit ? "HIT" : "MISS") << " " << - psstate->entry->url() ); + debugs(44, 3, "" << (htcp->hit ? "HIT" : "MISS") << " " << psstate->url()); ++ psstate->ping.n_recv; if (htcp->hit) { -- 2.47.2