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  1f4831c   Coverity 1022126 and 1022127: Dereference before null 
check
1f4831c is described below

commit 1f4831cbfa2c9416a9e8f32a06a2d945521fd342
Author: Gancho Tenev <gan...@apache.com>
AuthorDate: Wed May 10 12:07:40 2017 -0700

    Coverity 1022126 and 1022127: Dereference before null check
    
    Problem:
      CID 1022126 (#1 of 1): Dereference before null check (REVERSE_INULL)
      check_after_deref: Null-checking txn_sm->q_server_response_buffer 
suggests that it may be null, but it has already been dereferenced on all paths 
leading to the check.
      CID 1022127 (#1 of 1): Dereference before null check (REVERSE_INULL)
      check_after_deref: Null-checking txn_sm->q_server_request_buffer suggests 
that it may be null, but it has already been dereferenced on all paths leading 
to the check.
    
    Fix:
      Checked the return values on each step instead of all at the end.
---
 example/protocol/TxnSM.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/example/protocol/TxnSM.c b/example/protocol/TxnSM.c
index 316fd72..80f72df 100644
--- a/example/protocol/TxnSM.c
+++ b/example/protocol/TxnSM.c
@@ -441,14 +441,20 @@ state_build_and_send_request(TSCont contp, TSEvent event 
ATS_UNUSED, void *data
 
   txn_sm->q_pending_action = NULL;
 
-  txn_sm->q_server_request_buffer        = TSIOBufferCreate();
+  txn_sm->q_server_request_buffer = TSIOBufferCreate();
+  if (!txn_sm->q_server_request_buffer) {
+    return prepare_to_die(contp);
+  }
   txn_sm->q_server_request_buffer_reader = 
TSIOBufferReaderAlloc(txn_sm->q_server_request_buffer);
-
-  txn_sm->q_server_response_buffer       = TSIOBufferCreate();
+  if (!txn_sm->q_server_request_buffer_reader) {
+    return prepare_to_die(contp);
+  }
+  txn_sm->q_server_response_buffer = TSIOBufferCreate();
+  if (!txn_sm->q_server_response_buffer) {
+    return prepare_to_die(contp);
+  }
   txn_sm->q_cache_response_buffer_reader = 
TSIOBufferReaderAlloc(txn_sm->q_server_response_buffer);
-
-  if (!txn_sm->q_server_request_buffer || 
!txn_sm->q_server_request_buffer_reader || !txn_sm->q_server_response_buffer ||
-      !txn_sm->q_cache_response_buffer_reader) {
+  if (!txn_sm->q_cache_response_buffer_reader) {
     return prepare_to_die(contp);
   }
 

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

Reply via email to