Fix heap-use-after-free and memory leaks reported from test_node.cpp (#719)

Fix AddressSanitizer errors reported by test_node.cpp unit test.

Signed-off-by: Prajakta Gokhale <prajaktg@amazon.com>
This commit is contained in:
Prajakta Gokhale 2019-05-14 21:08:33 -07:00 committed by Dirk Thomas
parent ef41059a75
commit b17bbf31b3
2 changed files with 5 additions and 2 deletions

View file

@ -493,10 +493,10 @@ NodeParameters::set_parameters_atomically(const std::vector<rclcpp::Parameter> &
// assumption: the parameter to be undeclared should be in the parameter infos map
assert(it != parameters_.end());
if (it != parameters_.end()) {
// Remove it and update the parameter event message.
parameters_.erase(it);
// Update the parameter event message and remove it.
parameter_event_msg.deleted_parameters.push_back(
rclcpp::Parameter(it->first, it->second.value).to_parameter_msg());
parameters_.erase(it);
}
}

View file

@ -44,6 +44,9 @@ rcl_node_options_t_destructor(rcl_node_options_t * node_options)
"failed to finalize rcl node options: %s", rcl_get_error_string().str);
rcl_reset_error();
}
delete node_options;
node_options = nullptr;
}
}
} // namespace detail