Sync OpenBSD patchset 1165:

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.
This commit is contained in:
Tiago Cunha
2012-08-31 09:22:08 +00:00
parent 674545f7e6
commit 56e37487a8
4 changed files with 18 additions and 8 deletions

View File

@ -179,13 +179,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 *
@ -359,6 +354,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)
{