Skip to content

Commit

Permalink
Fix possible dangling pointer (#698)
Browse files Browse the repository at this point in the history
There are many instances where asynchronous calls using shared_ptrs
shared by reference could lead to possible dangling pointers.
---------

Co-authored-by: Haswell <[email protected]>
  • Loading branch information
StalinCCCP and Haswell authored Jan 7, 2025
1 parent 5b593b7 commit 1656f2a
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class local_tcp_server_endpoint_impl
bool add_connection(const client_t &_client,
const std::shared_ptr<connection> &_connection);
void remove_connection(const client_t &_client);
void accept_cbk(const connection::ptr& _connection,
void accept_cbk(connection::ptr _connection,
boost::system::error_code const &_error);
std::string get_remote_information(
const target_data_iterator_type _queue_iterator) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class local_uds_server_endpoint_impl: public local_uds_server_endpoint_base_impl
bool add_connection(const client_t &_client,
const std::shared_ptr<connection> &_connection);
void remove_connection(const client_t &_client);
void accept_cbk(const connection::ptr& _connection,
void accept_cbk(connection::ptr _connection,
boost::system::error_code const &_error);
std::string get_remote_information(
const target_data_iterator_type _queue_iterator) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class tcp_server_endpoint_impl: public tcp_server_endpoint_base_impl {

private:
void remove_connection(connection *_connection);
void accept_cbk(const connection::ptr& _connection,
void accept_cbk(connection::ptr _connection,
boost::system::error_code const &_error);
std::string get_remote_information(
const target_data_iterator_type _it) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void local_tcp_server_endpoint_impl::remove_connection(
}

void local_tcp_server_endpoint_impl::accept_cbk(
const connection::ptr& _connection, boost::system::error_code const &_error) {
connection::ptr _connection, boost::system::error_code const &_error) {
if (!_error) {
boost::system::error_code its_error;
endpoint_type remote;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void local_uds_server_endpoint_impl::remove_connection(
}

void local_uds_server_endpoint_impl::accept_cbk(
const connection::ptr& _connection, boost::system::error_code const &_error) {
connection::ptr _connection, boost::system::error_code const &_error) {
if (_error != boost::asio::error::bad_descriptor
&& _error != boost::asio::error::operation_aborted
&& _error != boost::asio::error::no_descriptors) {
Expand Down
2 changes: 1 addition & 1 deletion implementation/endpoints/src/tcp_server_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void tcp_server_endpoint_impl::remove_connection(
}
}

void tcp_server_endpoint_impl::accept_cbk(const connection::ptr& _connection,
void tcp_server_endpoint_impl::accept_cbk(connection::ptr _connection,
boost::system::error_code const& _error) {

if (!_error) {
Expand Down

0 comments on commit 1656f2a

Please sign in to comment.