Merge branch 'bugfix/freemodbus_fix_dereferencing_to_freed_element_issue' into 'master'

Bugfix/freemodbus fix dereferencing to freed element issue

Closes IDF-5402

See merge request idf/esp-modbus!24
This commit is contained in:
Alex Lisitsyn
2022-12-08 22:32:29 +08:00
3 changed files with 6 additions and 2 deletions

View File

@ -69,7 +69,7 @@ static void mbc_slave_free_descriptors(void) {
mb_slave_options_t* mbs_opts = &slave_interface_ptr->opts;
for (int descr_type = 0; descr_type < MB_PARAM_COUNT; descr_type++) {
for (it = LIST_FIRST(&mbs_opts->mbs_area_descriptors[descr_type]); it != NULL; it = LIST_NEXT(it, entries)) {
while ((it = LIST_FIRST(&mbs_opts->mbs_area_descriptors[descr_type]))) {
LIST_REMOVE(it, entries);
free(it);
}

View File

@ -205,6 +205,10 @@ static int xMBTCPPortAcceptConnection(int xListenSockId, char** pcIPAddr)
inet6_ntoa_r(((struct sockaddr_in6 *)&xSrcAddr)->sin6_addr, cAddrStr, sizeof(cAddrStr) - 1);
}
#endif
else {
// Make sure ss_family is valid
abort();
}
ESP_LOGI(TAG, "Socket (#%d), accept client connection from address: %s", xSockId, cAddrStr);
pcStr = calloc(1, strlen(cAddrStr) + 1);
if (pcStr && pcIPAddr) {

View File

@ -429,7 +429,7 @@ static void master_destroy_slave_list(char** table, size_t ip_table_size)
{
#if CONFIG_MB_MDNS_IP_RESOLVER
slave_addr_entry_t *it;
LIST_FOREACH(it, &slave_addr_list, entries) {
while ((it = LIST_FIRST(&slave_addr_list))) {
LIST_REMOVE(it, entries);
free(it);
}