lib60870 icon indicating copy to clipboard operation
lib60870 copied to clipboard

- CS104 connection: Fix use-after-free in handleConnection() (see #61)

Open S-trace opened this issue 5 years ago • 0 comments

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

S-trace avatar Nov 18 '19 15:11 S-trace