From a2004f8369b4407975cd227718047107527a41b0 Mon Sep 17 00:00:00 2001 From: Tomoya Fujita Date: Thu, 11 Feb 2021 11:08:16 +0900 Subject: [PATCH] Fix runtime error: reference binding to null pointer of type (#1547) (#1548) * Fix runtime error: reference binding to null pointer of type Signed-off-by: Tomoya.Fujita * delete cppcheck v1.89 workaround Signed-off-by: Tomoya.Fujita --- rclcpp/include/rclcpp/publisher_options.hpp | 7 +------ rclcpp/include/rclcpp/subscription_options.hpp | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/rclcpp/include/rclcpp/publisher_options.hpp b/rclcpp/include/rclcpp/publisher_options.hpp index 9547b34..21dba81 100644 --- a/rclcpp/include/rclcpp/publisher_options.hpp +++ b/rclcpp/include/rclcpp/publisher_options.hpp @@ -92,12 +92,7 @@ struct PublisherOptionsWithAllocator : public PublisherOptionsBase get_allocator() const { if (!this->allocator) { - // TODO(wjwwood): I would like to use the commented line instead, but - // cppcheck 1.89 fails with: - // Syntax Error: AST broken, binary operator '>' doesn't have two operands. - // return std::make_shared(); - std::shared_ptr tmp(new Allocator()); - return tmp; + return std::make_shared(); } return this->allocator; } diff --git a/rclcpp/include/rclcpp/subscription_options.hpp b/rclcpp/include/rclcpp/subscription_options.hpp index ebf4331..710699e 100644 --- a/rclcpp/include/rclcpp/subscription_options.hpp +++ b/rclcpp/include/rclcpp/subscription_options.hpp @@ -101,7 +101,7 @@ struct SubscriptionOptionsWithAllocator : public SubscriptionOptionsBase rcl_subscription_options_t result = rcl_subscription_get_default_options(); using AllocatorTraits = std::allocator_traits; using MessageAllocatorT = typename AllocatorTraits::template rebind_alloc; - auto message_alloc = std::make_shared(*allocator.get()); + auto message_alloc = std::make_shared(*this->get_allocator().get()); result.allocator = allocator::get_rcl_allocator(*message_alloc); result.qos = qos.get_rmw_qos_profile(); result.rmw_subscription_options.ignore_local_publications = this->ignore_local_publications;