Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the issues to dereference to nullptr #165

Merged
merged 2 commits into from
Oct 30, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 32 additions & 27 deletions rmw_fastrtps_cpp/src/rmw_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ rmw_create_client(
info->writer_guid_ = info->request_publisher_->getGuid();

rmw_client = rmw_client_allocate();
if (!rmw_client) {
RMW_SET_ERROR_MSG("failed to allocate memory for client");
goto fail;
}

rmw_client->implementation_identifier = eprosima_fastrtps_identifier;
rmw_client->data = info;
rmw_client->service_name = reinterpret_cast<const char *>(
Expand All @@ -204,42 +209,42 @@ rmw_create_client(
return rmw_client;

fail:
if (info->request_publisher_ != nullptr) {
Domain::removePublisher(info->request_publisher_);
}

if (info != nullptr) {
if (info->request_publisher_ != nullptr) {
Domain::removePublisher(info->request_publisher_);
}
if (info->response_subscriber_ != nullptr) {
Domain::removeSubscriber(info->response_subscriber_);
}

if (info->response_subscriber_ != nullptr) {
Domain::removeSubscriber(info->response_subscriber_);
}
if (info->listener_ != nullptr) {
delete info->listener_;
}

if (info->listener_ != nullptr) {
delete info->listener_;
if (impl) {
if (info->request_type_support_ != nullptr) {
_unregister_type(participant, info->request_type_support_, info->typesupport_identifier_);
}

if (impl) {
if (info->request_type_support_ != nullptr) {
_unregister_type(participant, info->request_type_support_, info->typesupport_identifier_);
}

if (info->response_type_support_ != nullptr) {
_unregister_type(participant, info->response_type_support_, info->typesupport_identifier_);
}
} else {
RCUTILS_LOG_ERROR_NAMED(
"rmw_fastrtps_cpp",
"leaking type support objects because node impl is null")
if (info->response_type_support_ != nullptr) {
_unregister_type(participant, info->response_type_support_, info->typesupport_identifier_);
}

delete info;
} else {
RCUTILS_LOG_ERROR_NAMED(
"rmw_fastrtps_cpp",
"leaking type support objects because node impl is null")
}

if (rmw_client->service_name != nullptr) {
rmw_free(const_cast<char *>(rmw_client->service_name));
rmw_client->service_name = nullptr;
delete info;
info = nullptr;

if (nullptr != rmw_client) {
if (rmw_client->service_name != nullptr) {
rmw_free(const_cast<char *>(rmw_client->service_name));
rmw_client->service_name = nullptr;
}
rmw_client_free(rmw_client);
}
rmw_client_free(rmw_client);

return nullptr;
}
Expand Down