mirror of
https://github.com/eledio-devices/thirdparty-AsyncTCPSock.git
synced 2025-10-30 16:15:40 +01:00
Clear write queue BEFORE calling discard callback
The discard callback (installed via onDisconnect()) can legitimately decide to destroy the AsyncTCP client, calling the destructors which in turn invalidate the write mutex object. Prior to this commit, calling _clearWriteQueue() (which takes said write mutex) risked accessing uninitialized memory and causing memory corruption. Fixed.
This commit is contained in:
@@ -718,9 +718,9 @@ void AsyncClient::_close(void)
|
||||
_socket = -1;
|
||||
xSemaphoreGive(_asyncsock_mutex);
|
||||
|
||||
_clearWriteQueue();
|
||||
if (_discard_cb) _discard_cb(_discard_cb_arg, this);
|
||||
_removeAllCallbacks();
|
||||
_clearWriteQueue();
|
||||
}
|
||||
|
||||
void AsyncClient::_error(int8_t err)
|
||||
@@ -731,10 +731,10 @@ void AsyncClient::_error(int8_t err)
|
||||
_socket = -1;
|
||||
xSemaphoreGive(_asyncsock_mutex);
|
||||
|
||||
_clearWriteQueue();
|
||||
if (_error_cb) _error_cb(_error_cb_arg, this, err);
|
||||
if (_discard_cb) _discard_cb(_discard_cb_arg, this);
|
||||
_removeAllCallbacks();
|
||||
_clearWriteQueue();
|
||||
}
|
||||
|
||||
size_t AsyncClient::space()
|
||||
|
||||
Reference in New Issue
Block a user