From 58e8e0eac841d6d337de3da4e2f81665c3cd3faa Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Tue, 21 Aug 2012 10:00:33 +0000 Subject: Fix up window reference counting and don't crash if the rename timer fires while the window is dead but still referenced. Fixes problem reported by Michael Scholz. --- window.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'window.c') diff --git a/window.c b/window.c index dcf1dd04..71225a9b 100644 --- a/window.c +++ b/window.c @@ -182,13 +182,8 @@ winlink_remove(struct winlinks *wwl, struct winlink *wl) free(wl->status_text); free(wl); - if (w != NULL) { - if (w->references == 0) - fatal("bad reference count"); - w->references--; - if (w->references == 0) - window_destroy(w); - } + if (w != NULL) + window_remove_ref(w); } struct winlink * @@ -362,6 +357,16 @@ window_destroy(struct window *w) free(w); } +void +window_remove_ref(struct window *w) +{ + if (w->references == 0) + fatal("bad reference count"); + w->references--; + if (w->references == 0) + window_destroy(w); +} + void window_set_name(struct window *w, const char *new_name) { -- cgit