You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gm...@apache.org on 2017/04/07 14:57:19 UTC

qpid-dispatch git commit: DISPATCH-741 - Fix Coverity leaks/errors reported in unit tests

Repository: qpid-dispatch
Updated Branches:
  refs/heads/master 3b12f0f0f -> b7b9d560f


DISPATCH-741 - Fix Coverity leaks/errors reported in unit tests


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/b7b9d560
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/b7b9d560
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/b7b9d560

Branch: refs/heads/master
Commit: b7b9d560fe0b1196544307cf41621d36818b07e9
Parents: 3b12f0f
Author: Ganesh Murthy <gm...@redhat.com>
Authored: Fri Apr 7 10:55:07 2017 -0400
Committer: Ganesh Murthy <gm...@redhat.com>
Committed: Fri Apr 7 10:55:07 2017 -0400

----------------------------------------------------------------------
 tests/field_test.c   |  2 +-
 tests/message_test.c | 15 ++++++++++++---
 2 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b7b9d560/tests/field_test.c
----------------------------------------------------------------------
diff --git a/tests/field_test.c b/tests/field_test.c
index 4be6e1a..6ad1263 100644
--- a/tests/field_test.c
+++ b/tests/field_test.c
@@ -299,7 +299,7 @@ static char* test_view_address_hash(void *context)
         char *ret = view_address_hash(context, iter, cases[idx].addr, cases[idx].view);
         qd_iterator_free(iter);
         if (ret) {
-            return strncpy(fail_text, ret, FAIL_TEXT_SIZE);
+            return strncpy(fail_text, ret, FAIL_TEXT_SIZE-1);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b7b9d560/tests/message_test.c
----------------------------------------------------------------------
diff --git a/tests/message_test.c b/tests/message_test.c
index 0d62f31..bc0156e 100644
--- a/tests/message_test.c
+++ b/tests/message_test.c
@@ -110,7 +110,7 @@ static char* test_receive_from_messenger(void *context)
     }
     qd_iterator_free(iter);
 
-    size_t test_len = (size_t)qd_message_field_length(msg, QD_FIELD_TO);
+    ssize_t  test_len = (size_t)qd_message_field_length(msg, QD_FIELD_TO);
     if (test_len != 11)
         return "Incorrect field length";
 
@@ -120,6 +120,11 @@ static char* test_receive_from_messenger(void *context)
     if (test_len - hdr_length != 11)
         return "Incorrect length returned from field_copy";
 
+    if (test_len < 0) {
+        pn_message_free(pn_msg);
+        qd_message_free(msg);
+        return "test_len cannot be less than zero";
+    }
     test_field[test_len] = '\0';
     if (strcmp(test_field + hdr_length, "test_addr_1") != 0) {
         pn_message_free(pn_msg);
@@ -178,8 +183,12 @@ static char* test_message_properties(void *context)
     qd_iterator_free(iter);
 
     iter = qd_message_field_iterator(msg, QD_FIELD_MESSAGE_ID);
-    if (!iter) return "Expected iterator for the 'message-id' field";
-    if (qd_iterator_length(iter) != 9) return "Bad length for message-id";
+    if (!iter)
+        return "Expected iterator for the 'message-id' field";
+    if (qd_iterator_length(iter) != 9) {
+        qd_iterator_free(iter);
+        return "Bad length for message-id";
+    }
     if (!qd_iterator_equal(iter, (const unsigned char *)"messageId")) {
         qd_iterator_free(iter);
         return "Invalid message-id";


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org