mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-07 16:23:38 +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
e3e25da792
commit
1c9456ac9d
@ -223,28 +223,19 @@ void ESP8266WebServer::sendContent_P(PGM_P content) {
|
|||||||
|
|
||||||
void ESP8266WebServer::sendContent_P(PGM_P content, size_t size) {
|
void ESP8266WebServer::sendContent_P(PGM_P content, size_t size) {
|
||||||
char contentUnit[HTTP_DOWNLOAD_UNIT_SIZE + 1];
|
char contentUnit[HTTP_DOWNLOAD_UNIT_SIZE + 1];
|
||||||
|
|
||||||
contentUnit[HTTP_DOWNLOAD_UNIT_SIZE] = '\0';
|
contentUnit[HTTP_DOWNLOAD_UNIT_SIZE] = '\0';
|
||||||
|
size_t remaining_size = size;
|
||||||
|
|
||||||
while (content != NULL) {
|
while (content != NULL && remaining_size > 0) {
|
||||||
size_t contentUnitLen;
|
size_t contentUnitLen = HTTP_DOWNLOAD_UNIT_SIZE;
|
||||||
PGM_P contentNext;
|
|
||||||
|
|
||||||
|
if (remaining_size < HTTP_DOWNLOAD_UNIT_SIZE) contentUnitLen = remaining_size;
|
||||||
// due to the memcpy signature, lots of casts are needed
|
// due to the memcpy signature, lots of casts are needed
|
||||||
contentNext = (PGM_P)memcpy_P((void*)contentUnit, (PGM_VOID_P)content, HTTP_DOWNLOAD_UNIT_SIZE);
|
memcpy_P((void*)contentUnit, (PGM_VOID_P)content, contentUnitLen);
|
||||||
|
|
||||||
if (contentNext == NULL) {
|
content += contentUnitLen;
|
||||||
// no terminator, more data available
|
remaining_size -= contentUnitLen;
|
||||||
content += HTTP_DOWNLOAD_UNIT_SIZE;
|
|
||||||
contentUnitLen = HTTP_DOWNLOAD_UNIT_SIZE;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// reached terminator
|
|
||||||
contentUnitLen = contentNext - content;
|
|
||||||
content = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (size < WIFICLIENT_MAX_PACKET_SIZE) contentUnitLen = size;
|
|
||||||
// write is so overloaded, had to use the cast to get it pick the right one
|
// write is so overloaded, had to use the cast to get it pick the right one
|
||||||
_currentClient.write((const char*)contentUnit, contentUnitLen);
|
_currentClient.write((const char*)contentUnit, contentUnitLen);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user