Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Remote close() caused null reference in write #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/ESPAsyncTCPbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ void AsyncTCPbuffer::_sendBuffer() {
return;
}

while((_client->space() > 0) && (_TXbufferRead->available() > 0) && _client->canSend()) {
while(_client != NULL && (_client->space() > 0) && (_TXbufferRead->available() > 0) && _client->canSend()) {

available = _TXbufferRead->available();

Expand All @@ -347,14 +347,16 @@ void AsyncTCPbuffer::_sendBuffer() {
// read data from buffer
_TXbufferRead->peek(out, available);

// send data
size_t send = _client->write((const char*) out, available);
if(send != available) {
DEBUG_ASYNC_TCP("[A-TCP] write failed send: %d available: %d \n", send, available);
}
if (_client) {
// send data
size_t send = _client->write((const char*) out, available);
if(send != available) {
DEBUG_ASYNC_TCP("[A-TCP] write failed send: %d available: %d \n", send, available);
}

// remove really send data from buffer
_TXbufferRead->remove(send);
// remove really send data from buffer
_TXbufferRead->remove(send);
}

// if buffer is empty and there is a other buffer in chain delete the empty one
if(_TXbufferRead->available() == 0 && _TXbufferRead->next != NULL) {
Expand Down