diff --git a/asio/include/asio/buffer.hpp b/asio/include/asio/buffer.hpp index 14d5ca0e..c41ac0dd 100644 --- a/asio/include/asio/buffer.hpp +++ b/asio/include/asio/buffer.hpp @@ -1920,7 +1920,8 @@ inline std::size_t buffer_copy_1(const mutable_buffer& target, std::size_t target_size = target.size(); std::size_t source_size = source.size(); std::size_t n = target_size < source_size ? target_size : source_size; - memcpy(target.data(), source.data(), n); + if (n > 0) + memcpy(target.data(), source.data(), n); return n; } diff --git a/asio/include/asio/generic/detail/impl/endpoint.ipp b/asio/include/asio/generic/detail/impl/endpoint.ipp index cfdfbbff..112c1b2b 100644 --- a/asio/include/asio/generic/detail/impl/endpoint.ipp +++ b/asio/include/asio/generic/detail/impl/endpoint.ipp @@ -94,7 +94,8 @@ void endpoint::init(const void* sock_addr, using namespace std; // For memset and memcpy. memset(&data_.generic, 0, sizeof(asio::detail::sockaddr_storage_type)); - memcpy(&data_.generic, sock_addr, sock_addr_size); + if (sock_addr_size > 0) + memcpy(&data_.generic, sock_addr, sock_addr_size); size_ = sock_addr_size; protocol_ = sock_protocol; diff --git a/asio/include/asio/local/detail/impl/endpoint.ipp b/asio/include/asio/local/detail/impl/endpoint.ipp index 5b06a5e8..af02fead 100644 --- a/asio/include/asio/local/detail/impl/endpoint.ipp +++ b/asio/include/asio/local/detail/impl/endpoint.ipp @@ -108,7 +108,8 @@ void endpoint::init(const char* path_name, std::size_t path_length) using namespace std; // For memcpy. data_.local = asio::detail::sockaddr_un_type(); data_.local.sun_family = AF_UNIX; - memcpy(data_.local.sun_path, path_name, path_length); + if (path_length > 0) + memcpy(data_.local.sun_path, path_name, path_length); path_length_ = path_length; // NUL-terminate normal path names. Names that start with a NUL are in the