From 106fcdcc1c9867db34a97a014bdbf27bcc182fd6 Mon Sep 17 00:00:00 2001 From: aleks Date: Wed, 19 Jan 2022 12:30:13 +0100 Subject: [PATCH] modbus: fix tcp slave destroy issues Closes https://github.com/espressif/esp-idf/issues/8211 --- .../freemodbus/tcp_slave/modbus_controller/mbc_tcp_slave.c | 2 +- components/freemodbus/tcp_slave/port/port_tcp_slave.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/components/freemodbus/tcp_slave/modbus_controller/mbc_tcp_slave.c b/components/freemodbus/tcp_slave/modbus_controller/mbc_tcp_slave.c index 16bf2f384a..a8ae1eba73 100644 --- a/components/freemodbus/tcp_slave/modbus_controller/mbc_tcp_slave.c +++ b/components/freemodbus/tcp_slave/modbus_controller/mbc_tcp_slave.c @@ -119,7 +119,7 @@ static esp_err_t mbc_tcp_slave_destroy(void) (void)vQueueDelete(mbs_opts->mbs_notification_queue_handle); (void)vEventGroupDelete(mbs_opts->mbs_event_group); (void)vMBTCPPortClose(); - + mbs_interface_ptr = NULL; vMBPortSetMode((UCHAR)MB_PORT_INACTIVE); return ESP_OK; } diff --git a/components/freemodbus/tcp_slave/port/port_tcp_slave.c b/components/freemodbus/tcp_slave/port/port_tcp_slave.c index 4706f61921..0603f93dd9 100644 --- a/components/freemodbus/tcp_slave/port/port_tcp_slave.c +++ b/components/freemodbus/tcp_slave/port/port_tcp_slave.c @@ -654,6 +654,7 @@ vMBTCPPortDisable( void ) xConfig.pxMbClientInfo[i] = NULL; } } + free(xConfig.pxMbClientInfo); close(xListenSock); xListenSock = -1; vMBTCPPortRespQueueDelete(xConfig.xRespQueueHandle);