From f13b1030f8b69ac7635760f6e9d0d39864947a05 Mon Sep 17 00:00:00 2001 From: Minggang Wang Date: Tue, 19 Jun 2018 17:52:57 +0800 Subject: [PATCH] Validate the buffer_ of CustomServiceRequest object before using it to instantiate class Cdr Before we are going to instantiate the fastcdr::Cdr class by using the member variable buffer_ of class CustomServiceRequest, we must ensure that the buffer_ can not be nullptr. This patch implements the validation. Fix #209 --- rmw_fastrtps_cpp/src/rmw_request.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rmw_fastrtps_cpp/src/rmw_request.cpp b/rmw_fastrtps_cpp/src/rmw_request.cpp index 13022d165..78d381c50 100644 --- a/rmw_fastrtps_cpp/src/rmw_request.cpp +++ b/rmw_fastrtps_cpp/src/rmw_request.cpp @@ -96,10 +96,10 @@ rmw_take_request( assert(info); CustomServiceRequest request = info->listener_->getRequest(); - eprosima::fastcdr::Cdr deser(*request.buffer_, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - eprosima::fastcdr::Cdr::DDS_CDR); if (request.buffer_ != nullptr) { + eprosima::fastcdr::Cdr deser(*request.buffer_, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + eprosima::fastcdr::Cdr::DDS_CDR); _deserialize_ros_message(deser, ros_request, info->request_type_support_, info->typesupport_identifier_);