From 3f3d0f9c622c7f3ac52064a843daf9b8212ad779 Mon Sep 17 00:00:00 2001 From: tomoya Date: Wed, 10 Feb 2021 14:30:53 +0900 Subject: [PATCH] Fix runtime error: reference binding to null pointer of type (#1547) * 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 ff038d15f4..2e12c12bcb 100644 --- a/rclcpp/include/rclcpp/publisher_options.hpp +++ b/rclcpp/include/rclcpp/publisher_options.hpp @@ -95,12 +95,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 c3d509698d..ade1bb8e9f 100644 --- a/rclcpp/include/rclcpp/subscription_options.hpp +++ b/rclcpp/include/rclcpp/subscription_options.hpp @@ -104,7 +104,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;