diff -r 88c398efc728 -r fcfc3dbe85fa thermferm/rdconfig.c --- a/thermferm/rdconfig.c Thu Aug 02 13:39:30 2018 +0200 +++ b/thermferm/rdconfig.c Fri Aug 03 16:13:17 2018 +0200 @@ -42,12 +42,12 @@ void killconfig(void) { - units_list *tmp2; - profiles_list *tmp3; - prof_step *tmp4; - devices_list *device; + units_list *tmp2, *oldtmp2; + profiles_list *tmp3, *oldtmp3; + prof_step *tmp4, *oldtmp4; + devices_list *device, *olddev; #ifdef USE_SIMULATOR - simulator_list *simulator; + simulator_list *simulator, *oldsim; #endif if (Config.name) @@ -79,7 +79,8 @@ free(Config.uuid); Config.uuid = NULL; - for (tmp2 = Config.units; tmp2; tmp2 = tmp2->next) { + for (tmp2 = Config.units; tmp2; tmp2 = oldtmp2) { + oldtmp2 = tmp2->next; if (tmp2->uuid) free(tmp2->uuid); if (tmp2->product_uuid) @@ -108,17 +109,23 @@ free(tmp2->psu_address); if (tmp2->profile) free(tmp2->profile); + if (tmp2->PID_cool) + free(tmp2->PID_cool); + if (tmp2->PID_heat) + free(tmp2->PID_heat); free(tmp2); } Config.units = NULL; - for (tmp3 = Config.profiles; tmp3; tmp3 = tmp3->next) { + for (tmp3 = Config.profiles; tmp3; tmp3 = oldtmp3) { + oldtmp3 = tmp3->next; if (tmp3->uuid) free(tmp3->uuid); if (tmp3->name) free(tmp3->name); if (tmp3->steps) { - for (tmp4 = tmp3->steps; tmp4; tmp4 = tmp4->next) { + for (tmp4 = tmp3->steps; tmp4; tmp4 = oldtmp4) { + oldtmp4 = tmp4->next; free(tmp4); } } @@ -126,7 +133,8 @@ } Config.profiles = NULL; - for (device = Config.devices; device; device = device->next) { + for (device = Config.devices; device; device = olddev) { + olddev = device->next; if (device->uuid) free(device->uuid); if (device->address) @@ -140,7 +148,8 @@ Config.devices = NULL; #ifdef USE_SIMULATOR - for (simulator = Config.simulators; simulator; simulator = simulator->next) { + for (simulator = Config.simulators; simulator; simulator = oldsim) { + oldsim = simulator->next; if (simulator->uuid) free(simulator->uuid); if (simulator->name) @@ -2266,6 +2275,8 @@ xmlFree(key); } if ((!xmlStrcmp(cur->name, (const xmlChar *)"MQTT_HOST"))) { + if (Config.mqtt_host) + free(Config.mqtt_host); Config.mqtt_host = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); } if ((!xmlStrcmp(cur->name, (const xmlChar *)"MQTT_PORT"))) {