From 825c6bc70910e5b0d519ca0afc071a17ec7a9a62 Mon Sep 17 00:00:00 2001 From: Minggang Wang Date: Wed, 20 Jun 2018 02:42:13 +0800 Subject: [PATCH] Validate the buffer_ of CustomServiceRequest object before using it to (#210) 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_);