8000 Merge pull request #514 from simap/master · DerialE/arduinoWebSockets@c3f01e4 · GitHub
[go: up one dir, main page]

Skip to content

Commit c3f01e4

Browse files
authored
Merge pull request Links2004#514 from simap/master
read can return -1, check for this to avoid corrupting protocol
2 parents 04e4be0 + 5169119 commit c3f01e4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/WebSockets.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ bool WebSockets::readCb(WSclient_t * client, uint8_t * out, size_t n, WSreadWait
595595

596596
#else
597597
unsigned long t = millis();
598-
size_t len;
598+
ssize_t len;
599599
DEBUG_WEBSOCKETS("[readCb] n: %zu t: %lu\n", n, t);
600600
while(n > 0) {
601601
if(client->tcp == NULL) {
@@ -633,7 +633,7 @@ bool WebSockets::readCb(WSclient_t * client, uint8_t * out, size_t n, WSreadWait
633633
}
634634

635635
len = client->tcp->read((uint8_t *)out, n);
636-
if(len) {
636+
if(len > 0) {
637637
t = millis();
638638
out += len;
639639
n -= len;

0 commit comments

Comments
 (0)
0