Skip to content

Commit 9cc96f2

Browse files
authored
Fixed segfault when initializing TCP server. "Client" is 0 there. (#76)
1 parent 8938bea commit 9cc96f2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libmodbus/modbus-tcp.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,10 @@ static void _modbus_tcp_close(modbus_t *ctx)
499499
#ifdef ARDUINO
500500
modbus_tcp_t *ctx_tcp = (modbus_tcp_t*)ctx->backend_data;
501501

502-
ctx_tcp->client->stop();
502+
if(ctx_tcp && ctx_tcp->client) {
503+
ctx_tcp->client->stop();
504+
}
505+
503506
#else
504507
if (ctx->s != -1) {
505508
shutdown(ctx->s, SHUT_RDWR);

0 commit comments

Comments
 (0)