Fix dap::Socket::read() when recv() errors

Identified by @kuafuwang.

Fixes #29
This commit is contained in:
Ben Clayton 2020-05-26 10:28:51 +01:00
parent 9e313445bb
commit ad9b4588f2

View File

@ -158,7 +158,9 @@ class dap::Socket::Shared : public dap::ReaderWriter {
if (s == InvalidSocket) { if (s == InvalidSocket) {
return 0; return 0;
} }
return recv(s, reinterpret_cast<char*>(buffer), static_cast<int>(bytes), 0); auto len =
recv(s, reinterpret_cast<char*>(buffer), static_cast<int>(bytes), 0);
return (len < 0) ? 0 : len;
} }
bool write(const void* buffer, size_t bytes) { bool write(const void* buffer, size_t bytes) {