From 62862ecc3ed4be097d09502d57d91543f3c41bf8 Mon Sep 17 00:00:00 2001 From: michael-west Date: Fri, 7 Mar 2014 12:23:34 -0800 Subject: Fix for Bug #378: rpc_client::call() dereferences NULL pointers - Added check for empty data before write --- host/lib/transport/nirio/rpc/rpc_client.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'host/lib/transport') diff --git a/host/lib/transport/nirio/rpc/rpc_client.cpp b/host/lib/transport/nirio/rpc/rpc_client.cpp index c16a844c1..32a40a576 100644 --- a/host/lib/transport/nirio/rpc/rpc_client.cpp +++ b/host/lib/transport/nirio/rpc/rpc_client.cpp @@ -133,9 +133,12 @@ const boost::system::error_code& rpc_client::call( CHAIN_BLOCKING_XFER( boost::asio::write(_socket, boost::asio::buffer(&_request.header, sizeof(_request.header))), sizeof(_request.header), status); - CHAIN_BLOCKING_XFER( - boost::asio::write(_socket, boost::asio::buffer(&(*_request.data.begin()), _request.data.size())), - _request.data.size(), status); + if (not _request.data.empty()) + { + CHAIN_BLOCKING_XFER( + boost::asio::write(_socket, boost::asio::buffer(&(*_request.data.begin()), _request.data.size())), + _request.data.size(), status); + } } catch (boost::exception&) { status = false; } -- cgit v1.2.3