Don't try to receive 0 sized data
This commit is contained in:
@@ -501,6 +501,8 @@ wivrn::deserialization_packet wivrn::TCP::receive_raw()
|
|||||||
capacity_left = new_size - data.size_bytes();
|
capacity_left = new_size - data.size_bytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (capacity_left > 0)
|
||||||
|
{
|
||||||
ssize_t received_size = recv(fd, &*data.end(), capacity_left, MSG_DONTWAIT);
|
ssize_t received_size = recv(fd, &*data.end(), capacity_left, MSG_DONTWAIT);
|
||||||
|
|
||||||
if (received_size < 0)
|
if (received_size < 0)
|
||||||
@@ -519,6 +521,8 @@ wivrn::deserialization_packet wivrn::TCP::receive_raw()
|
|||||||
|
|
||||||
data = std::span(data.data(), data.size() + received_size);
|
data = std::span(data.data(), data.size() + received_size);
|
||||||
capacity_left -= received_size;
|
capacity_left -= received_size;
|
||||||
|
}
|
||||||
|
|
||||||
if (data.size_bytes() < sizeof(uint16_t))
|
if (data.size_bytes() < sizeof(uint16_t))
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user