@@ -131,15 +131,16 @@ handle_scan(TSCont contp, TSEvent event, void *edata)
131131 const char s1[] = " URL: " , s2[] = " \n " ;
132132 cstate->total_bytes += TSIOBufferWrite (cstate->resp_buffer , s1, sizeof (s1) - 1 );
133133 TSCacheHttpInfoReqGet (cache_infop, &req_bufp, &req_hdr_loc);
134- TSHttpHdrUrlGet (req_bufp, req_hdr_loc, &url_loc);
135- url = TSUrlStringGet (req_bufp, url_loc, &url_len);
134+ if (TS_SUCCESS == TSHttpHdrUrlGet (req_bufp, req_hdr_loc, &url_loc)) {
135+ url = TSUrlStringGet (req_bufp, url_loc, &url_len);
136136
137- cstate->total_bytes += TSIOBufferWrite (cstate->resp_buffer , url, url_len);
138- cstate->total_bytes += TSIOBufferWrite (cstate->resp_buffer , s2, sizeof (s2) - 1 );
137+ cstate->total_bytes += TSIOBufferWrite (cstate->resp_buffer , url, url_len);
138+ cstate->total_bytes += TSIOBufferWrite (cstate->resp_buffer , s2, sizeof (s2) - 1 );
139139
140- TSfree (url);
141- TSHandleMLocRelease (req_bufp, req_hdr_loc, url_loc);
142- TSHandleMLocRelease (req_bufp, TS_NULL_MLOC, req_hdr_loc);
140+ TSfree (url);
141+ TSHandleMLocRelease (req_bufp, req_hdr_loc, url_loc);
142+ TSHandleMLocRelease (req_bufp, TS_NULL_MLOC, req_hdr_loc);
143+ }
143144
144145 // print the response headers
145146 TSCacheHttpInfoRespGet (cache_infop, &resp_bufp, &resp_hdr_loc);
0 commit comments