Skip to content

Commit 3279248

Browse files
devyted-a-v
authored andcommitted
Fix pointer arithmetic (#6830)
Actually advance position while looping
1 parent 8f6e0dd commit 3279248

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -678,18 +678,18 @@ int HTTPClient::sendRequest(const char * type, const uint8_t * payload, size_t s
678678

679679
// send Payload if needed
680680
if (payload && size > 0) {
681-
size_t byteswritten = 0;
681+
size_t bytesWritten = 0;
682682
const uint8_t *p = payload;
683-
while (byteswritten < size) {
683+
while (bytesWritten < size) {
684684
int written;
685685
int towrite = std::min((int)size, (int)HTTP_TCP_BUFFER_SIZE);
686-
written = _client->write(p, towrite);
686+
written = _client->write(p + bytesWritten, towrite);
687687
if (written < 0) {
688688
return returnError(HTTPC_ERROR_SEND_PAYLOAD_FAILED);
689689
} else if (written == 0) {
690690
return returnError(HTTPC_ERROR_CONNECTION_LOST);
691691
}
692-
byteswritten += written;
692+
bytesWritten += written;
693693
size -= written;
694694
}
695695
}

0 commit comments

Comments
 (0)