This is an automated email from the ASF dual-hosted git repository.

gancho pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

The following commit(s) were added to refs/heads/master by this push:
       new  cf27627   Coverity 1022060: Unchecked return value
cf27627 is described below

commit cf2762719e8dfc4d68f5e267ee2ec033ccb95f6b
Author: Gancho Tenev <gan...@apache.com>
AuthorDate: Mon May 8 11:03:30 2017 -0700

    Coverity 1022060: Unchecked return value
    
    Problem:
      CID 1022060 (#1 of 1): Unchecked return value (CHECKED_RETURN)
    
    Solution:
      Added a check for the return value.
---
 example/cache_scan/cache_scan.cc | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/example/cache_scan/cache_scan.cc b/example/cache_scan/cache_scan.cc
index f14e96e..3a96c34 100644
--- a/example/cache_scan/cache_scan.cc
+++ b/example/cache_scan/cache_scan.cc
@@ -131,15 +131,16 @@ handle_scan(TSCont contp, TSEvent event, void *edata)
     const char s1[] = "URL: ", s2[] = "\n";
     cstate->total_bytes += TSIOBufferWrite(cstate->resp_buffer, s1, sizeof(s1) 
- 1);
     TSCacheHttpInfoReqGet(cache_infop, &req_bufp, &req_hdr_loc);
-    TSHttpHdrUrlGet(req_bufp, req_hdr_loc, &url_loc);
-    url = TSUrlStringGet(req_bufp, url_loc, &url_len);
+    if (TS_SUCCESS == TSHttpHdrUrlGet(req_bufp, req_hdr_loc, &url_loc)) {
+      url = TSUrlStringGet(req_bufp, url_loc, &url_len);
 
-    cstate->total_bytes += TSIOBufferWrite(cstate->resp_buffer, url, url_len);
-    cstate->total_bytes += TSIOBufferWrite(cstate->resp_buffer, s2, sizeof(s2) 
- 1);
+      cstate->total_bytes += TSIOBufferWrite(cstate->resp_buffer, url, 
url_len);
+      cstate->total_bytes += TSIOBufferWrite(cstate->resp_buffer, s2, 
sizeof(s2) - 1);
 
-    TSfree(url);
-    TSHandleMLocRelease(req_bufp, req_hdr_loc, url_loc);
-    TSHandleMLocRelease(req_bufp, TS_NULL_MLOC, req_hdr_loc);
+      TSfree(url);
+      TSHandleMLocRelease(req_bufp, req_hdr_loc, url_loc);
+      TSHandleMLocRelease(req_bufp, TS_NULL_MLOC, req_hdr_loc);
+    }
 
     // print the response headers
     TSCacheHttpInfoRespGet(cache_infop, &resp_bufp, &resp_hdr_loc);

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>'].

Reply via email to