diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-10-07 11:20:29 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-10-07 11:20:29 +0100 |
commit | cf3d0eaf47a56a52b355d8faf4e59685396f9c05 (patch) | |
tree | ecb982bc178f8eaab7f8a12436d83526778ff331 /src/time.c | |
parent | 0937b9fb244949b7ce9bfcf8398d7495b9b6aa85 (diff) |
patch 9.0.0682: crash when popup with deleted timer is closedv9.0.0682
Problem: Crash when popup with deleted timer is closed. (Igbanam
Ogbuluijah)
Solution: Check the timer still exists. (closes #11301)
Diffstat (limited to 'src/time.c')
-rw-r--r-- | src/time.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/time.c b/src/time.c index 901222c195..f8e8c5afe2 100644 --- a/src/time.c +++ b/src/time.c @@ -777,15 +777,27 @@ set_ref_in_timer(int copyID) return abort; } +/* + * Return TRUE if "timer" exists in the list of timers. + */ + int +timer_valid(timer_T *timer) +{ + if (timer == NULL) + return FALSE; + for (timer_T *t = first_timer; t != NULL; t = t->tr_next) + if (t == timer) + return TRUE; + return FALSE; +} + # if defined(EXITFREE) || defined(PROTO) void timer_free_all() { - timer_T *timer; - while (first_timer != NULL) { - timer = first_timer; + timer_T *timer = first_timer; remove_timer(timer); free_timer(timer); } |