added validity check for connection handle
[platform/core/api/connection.git] / 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;