Backport of:

commit 8232b83d3fa47a1399f155cb829db829369fbae9 (refs/remotes/origin/v3.5)
Author: squidadm <squidadm@users.noreply.github.com>
Date:   2018-01-21 08:07:08 +1300

    Fix indirect IP logging for transactions without a client connection (#129) (#136)

Index: squid3-3.3.8/src/client_side_request.cc
===================================================================
--- squid3-3.3.8.orig/src/client_side_request.cc	2018-02-01 10:09:48.095820345 -0500
+++ squid3-3.3.8/src/client_side_request.cc	2018-02-01 10:11:10.528102117 -0500
@@ -532,8 +532,8 @@ clientFollowXForwardedForCheck(allow_t a
         * Ensure that the access log shows the indirect client
         * instead of the direct client.
         */
-        ConnStateData *conn = http->getConn();
-        conn->log_addr = request->indirect_client_addr;
+        if (ConnStateData *conn = http->getConn())
+            conn->log_addr = request->indirect_client_addr;
     }
     request->x_forwarded_for_iterator.clean();
     request->flags.done_follow_x_forwarded_for=true;
