Skip to content

Commit 883d473

Browse files
committed
WiFiOTA.cpp - check for positive return value from read(buff,size)
some libraries return -1 if no data are available
1 parent ce1d1ad commit 883d473

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/WiFiOTA.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,12 @@ void WiFiOTAClass::pollServer(Client& client)
299299
while (client.connected() && read < contentLength) {
300300
while (client.available()) {
301301
int l = client.read(buff, sizeof(buff));
302-
for (int i = 0; i < l; i++) {
303-
_storage->write(buff[i]);
302+
if (l > 0) { // some libraries return -1 if no data are available
303+
for (int i = 0; i < l; i++) {
304+
_storage->write(buff[i]);
305+
}
306+
read += l;
304307
}
305-
read += l;
306308
}
307309
}
308310

0 commit comments

Comments
 (0)