Fix crash when calling stop_timeout from the callback of a repeated timer
o9000 o9000
1 files changed,
9 insertions(+),
2 deletions(-)
jump to
M
src/util/timer.c
→
src/util/timer.c
@@ -389,12 +389,19 @@ multi_timeout_handler* mth = arg;
struct timespec cur_time; clock_gettime(CLOCK_MONOTONIC, &cur_time); GSList* it = mth->timeout_list; +start: while (it) { timeout* t = it->data; if (++t->multi_timeout->current_count >= t->multi_timeout->count_to_expiration) { t->_callback(t->arg); - t->multi_timeout->current_count = 0; - t->timeout_expires = add_msec_to_timespec(cur_time, t->interval_msec); + if (multi_timeouts && g_hash_table_lookup(multi_timeouts, t)) { + // Timer still exists + t->multi_timeout->current_count = 0; + t->timeout_expires = add_msec_to_timespec(cur_time, t->interval_msec); + } else { + it = mth->timeout_list; + goto start; + } } it = it->next; }