Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory initialization of buffer vector. #26

Merged
merged 2 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/tcp_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ReturnStatuses TCPInterface::read(std::vector<uint8_t> *msg)

error_.assign(boost::system::errc::success, boost::system::system_category());

msg->reserve(10000);
msg->resize(socket_.available(), 0);
JWhitleyWork marked this conversation as resolved.
Show resolved Hide resolved
boost::asio::read(socket_, boost::asio::buffer(*msg), error_);

// Reset the io service so that it is available for the next call to TCPInterface::read
Expand All @@ -93,7 +93,7 @@ ReturnStatuses TCPInterface::read_exactly(std::vector<uint8_t> *msg, const size_

error_.assign(boost::system::errc::success, boost::system::system_category());

msg->reserve(bytes_to_read);
msg->resize(bytes_to_read, 0);
boost::asio::read(socket_, boost::asio::buffer(*msg), boost::asio::transfer_exactly(bytes_to_read));

// Reset the io service so that it is available for the next call to TCPInterface::read_exactly
Expand Down
2 changes: 1 addition & 1 deletion src/udp_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ ReturnStatuses UDPInterface::read(std::vector<uint8_t> *msg)
return ReturnStatuses::SOCKET_CLOSED;

boost::system::error_code ec;
msg->reserve(10000);
msg->resize(socket_.available(), 0);
socket_.receive(boost::asio::buffer(*msg), 0, ec);

if (ec.value() == boost::system::errc::success)
Expand Down