added validity check for connection handle 91/241191/2
authorRahul Jain <rahul.jain@samsung.com>
Tue, 18 Aug 2020 11:02:24 +0000 (16:32 +0530)
committerRahul Jain <rahul.jain@samsung.com>
Tue, 18 Aug 2020 11:08:30 +0000 (16:38 +0530)
if connection handle is null, then _connection_unset_cs_tid() will be crash.

Change-Id: Iaba3160becf7b15ea9cec3127e00f1245c767229

src/connection.c

index a00868f..fe594bb 100755 (executable)
@@ -233,6 +233,14 @@ EXPORT_API int connection_destroy_cs(int tid, connection_h connection)
        int rv;
 
        CONN_LOCK;
+
+       if (!(__connection_check_handle_validity(connection))) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
+       CONNECTION_LOG(CONNECTION_INFO, "Destroy connection handle: %p", connection);
        _connection_unset_cs_tid(tid, connection);
        CONN_UNLOCK;