Skip to content

Commit ddd28c1

Browse files
committed
If client disconnects while in the sending loop, check its pointer for null check
1 parent 26f6253 commit ddd28c1

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/AsyncEventSource.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,12 @@ bool AsyncEventSourceClient::_queueMessage(const char *message, size_t len) {
217217
forcing Q run will only eat more heap ram and blow the buffer, let's just keep data in our own queue
218218
the queue will be processed at least on each onAck()/onPoll() call from AsyncTCP
219219
*/
220-
if (_messageQueue.size() < SSE_MAX_QUEUED_MESSAGES >> 2 && _client->canSend()) {
220+
if (_client && _client->canSend() && _messageQueue.size() < SSE_MAX_QUEUED_MESSAGES >> 2) {
221221
_runQueue();
222+
223+
} else if (!_client) {
224+
_messageQueue.clear();
225+
return false;
222226
}
223227

224228
return true;

0 commit comments

Comments
 (0)