1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Fix pointer arithmetic (#6830)

Actually advance position while looping
This commit is contained in:
Develo 2019-11-24 07:42:17 -03:00 committed by david gauchard
parent 8f6e0dd339
commit 32792483cc

View File

@ -678,18 +678,18 @@ int HTTPClient::sendRequest(const char * type, const uint8_t * payload, size_t s
// send Payload if needed
if (payload && size > 0) {
size_t byteswritten = 0;
size_t bytesWritten = 0;
const uint8_t *p = payload;
while (byteswritten < size) {
while (bytesWritten < size) {
int written;
int towrite = std::min((int)size, (int)HTTP_TCP_BUFFER_SIZE);
written = _client->write(p, towrite);
written = _client->write(p + bytesWritten, towrite);
if (written < 0) {
return returnError(HTTPC_ERROR_SEND_PAYLOAD_FAILED);
} else if (written == 0) {
return returnError(HTTPC_ERROR_CONNECTION_LOST);
}
byteswritten += written;
bytesWritten += written;
size -= written;
}
}