DISPATCH-847 - Fixed Coverity issue 162701 (Dereference null pointer)

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

Branch: refs/heads/master
Commit: 0ed04a2c335b59b580e35943d02b8112d0540ea2
Parents: 938cdfa
Author: Ted Ross <tr...@redhat.com>
Authored: Wed Oct 4 10:15:30 2017 -0400
Committer: Ted Ross <tr...@redhat.com>
Committed: Wed Oct 4 10:15:30 2017 -0400

----------------------------------------------------------------------
 src/server.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0ed04a2c/src/server.c
----------------------------------------------------------------------
diff --git a/src/server.c b/src/server.c
index 5f9a51e..e9cdcc3 100644
--- a/src/server.c
+++ b/src/server.c
@@ -665,6 +665,9 @@ static void on_connection_bound(qd_server_t *server, 
pn_event_t *e) {
 
 static void invoke_deferred_calls(qd_connection_t *conn, bool discard)
 {
+    if (!conn)
+        return;
+
     // Lock access to deferred_calls, other threads may concurrently add to 
it.  Invoke
     // the calls outside of the critical section.
     //
@@ -822,7 +825,7 @@ static bool handle(qd_server_t *qd_server, pn_event_t *e) {
         qdr_handle_authentication_service_connection_event(e);
         return true;
     }
-    qd_connection_t *ctx  = pn_conn ? (qd_connection_t*) 
pn_connection_get_context(pn_conn) : NULL;
+    qd_connection_t *ctx = pn_conn ? (qd_connection_t*) 
pn_connection_get_context(pn_conn) : NULL;
 
     switch (pn_event_type(e)) {
 
@@ -857,9 +860,9 @@ static bool handle(qd_server_t *qd_server, pn_event_t *e) {
 
     case PN_CONNECTION_REMOTE_OPEN:
         // If we are transitioning to the open state, notify the client via 
callback.
-        if (ctx->timer)
+        if (ctx && ctx->timer)
             qd_timer_free(ctx->timer);
-        if (!ctx->opened) {
+        if (ctx && !ctx->opened) {
             ctx->opened = true;
             if (ctx->connector) {
                 ctx->connector->delay = 2000;  // Delay re-connect in case 
there is a recurring error
@@ -1235,6 +1238,9 @@ const qd_server_config_t *qd_connection_config(const 
qd_connection_t *conn)
 
 void qd_connection_invoke_deferred(qd_connection_t *conn, qd_deferred_t call, 
void *context)
 {
+    if (!conn)
+        return;
+
     qd_deferred_call_t *dc = new_qd_deferred_call_t();
     DEQ_ITEM_INIT(dc);
     dc->call    = call;


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

Reply via email to