summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/timer.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/common/timer.c b/src/common/timer.c
index 954582134..6bf5cdbda 100644
--- a/src/common/timer.c
+++ b/src/common/timer.c
@@ -294,11 +294,18 @@ int do_timer(unsigned int tick) {
void timer_final() {
struct timer_func_list* tfl = tfl_root, *tfl2;
+// while (tfl) {
+// tfl2 = tfl;
+// aFree(tfl->name);
+// aFree(tfl);
+// tfl = tfl2->next; // access on already freed memory
+// }
+
while (tfl) {
- tfl2 = tfl;
- aFree(tfl->name);
+ tfl2 = tfl->next; // copy next pointer
+ aFree(tfl->name); // free structures
aFree(tfl);
- tfl = tfl2->next;
+ tfl = tfl2; // use copied pointer for next cycle
}
if (timer_data) aFree(timer_data);