mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-22 21:23:07 +03:00
fix bug in WiFiClient::write_P/ESP8266WebServer::sendContent_P introduced few minutes ago when changing memccpy_P to memcpy_P
This commit is contained in:
parent
82748a872c
commit
e3e25da792
@ -186,24 +186,19 @@ size_t WiFiClient::write_P(PGM_P buf, size_t size)
|
|||||||
|
|
||||||
char chunkUnit[WIFICLIENT_MAX_PACKET_SIZE + 1];
|
char chunkUnit[WIFICLIENT_MAX_PACKET_SIZE + 1];
|
||||||
chunkUnit[WIFICLIENT_MAX_PACKET_SIZE] = '\0';
|
chunkUnit[WIFICLIENT_MAX_PACKET_SIZE] = '\0';
|
||||||
while (buf != NULL)
|
size_t remaining_size = size;
|
||||||
{
|
|
||||||
size_t chunkUnitLen;
|
while (buf != NULL && remaining_size > 0) {
|
||||||
PGM_P chunkNext;
|
size_t chunkUnitLen = WIFICLIENT_MAX_PACKET_SIZE;
|
||||||
chunkNext = (PGM_P)memcpy_P((void*)chunkUnit, (PGM_VOID_P)buf, WIFICLIENT_MAX_PACKET_SIZE);
|
|
||||||
if (chunkNext == NULL)
|
if (remaining_size < WIFICLIENT_MAX_PACKET_SIZE) chunkUnitLen = remaining_size;
|
||||||
{
|
// due to the memcpy signature, lots of casts are needed
|
||||||
// no terminator, more data available
|
memcpy_P((void*)chunkUnit, (PGM_VOID_P)buf, chunkUnitLen);
|
||||||
buf += WIFICLIENT_MAX_PACKET_SIZE;
|
|
||||||
chunkUnitLen = WIFICLIENT_MAX_PACKET_SIZE;
|
buf += chunkUnitLen;
|
||||||
}
|
remaining_size -= chunkUnitLen;
|
||||||
else
|
|
||||||
{
|
// write is so overloaded, had to use the cast to get it pick the right one
|
||||||
// reached terminator
|
|
||||||
chunkUnitLen = chunkNext - buf;
|
|
||||||
buf = NULL;
|
|
||||||
}
|
|
||||||
if (size < WIFICLIENT_MAX_PACKET_SIZE) chunkUnitLen = size;
|
|
||||||
_client->write((const char*)chunkUnit, chunkUnitLen);
|
_client->write((const char*)chunkUnit, chunkUnitLen);
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user