Skip to content

Commit cf27627

Browse files
Gancho Tenevgtenev
authored andcommitted
Coverity 1022060: Unchecked return value
Problem: CID 1022060 (#1 of 1): Unchecked return value (CHECKED_RETURN) Solution: Added a check for the return value.
1 parent 1e4fd10 commit cf27627

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

example/cache_scan/cache_scan.cc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)