lib60870
lib60870 copied to clipboard
- CS104 connection: Fix use-after-free in handleConnection() (see #61)
If user calls CS104_Connection_destroy() in connectionHandler() on CONNECTION_CLOSED event - two memory errors will occur in handleConnection() because self is not valid anymore (after returning from connectionHandler() which called CS104_Connection_destroy() before):
(cs104_connection.c:817) Socket_destroy(self->socket); (cs104_connection.c:821) self->running = false;
So, it's necessary to call connectionHandler() with CONNECTION_CLOSED event right before exiting from handleConnection().
Fixes https://github.com/mz-automation/lib60870/issues/61