Sync OpenBSD patchset 852:

Check if the index is in use and fail before creating the child process,
rather than leaving a stray child on failure.
This commit is contained in:
Tiago Cunha
2011-02-15 15:09:52 +00:00
parent d0d1c0e486
commit 4e4568cade
3 changed files with 37 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $Id: window.c,v 1.144 2011-01-21 23:44:13 tcunha Exp $ */
/* $Id: window.c,v 1.145 2011-02-15 15:09:52 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -120,7 +120,7 @@ winlink_count(struct winlinks *wwl)
}
struct winlink *
winlink_add(struct winlinks *wwl, struct window *w, int idx)
winlink_add(struct winlinks *wwl, int idx)
{
struct winlink *wl;
@ -132,14 +132,18 @@ winlink_add(struct winlinks *wwl, struct window *w, int idx)
wl = xcalloc(1, sizeof *wl);
wl->idx = idx;
wl->window = w;
RB_INSERT(winlinks, wwl, wl);
w->references++;
return (wl);
}
void
winlink_set_window(struct winlink *wl, struct window *w)
{
wl->window = w;
w->references++;
}
void
winlink_remove(struct winlinks *wwl, struct winlink *wl)
{
@ -150,11 +154,13 @@ winlink_remove(struct winlinks *wwl, struct winlink *wl)
xfree(wl->status_text);
xfree(wl);
if (w->references == 0)
fatal("bad reference count");
w->references--;
if (w->references == 0)
window_destroy(w);
if (w != NULL) {
if (w->references == 0)
fatal("bad reference count");
w->references--;
if (w->references == 0)
window_destroy(w);
}
}
struct winlink *