diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2011-01-25 22:31:50 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2011-01-25 22:31:50 +0000 |
commit | 1270f8fed8642ac61d14be6a3aeb8d002db82a78 (patch) | |
tree | 737023d730f81a567c7666077b03b57f07401310 /window.c | |
parent | 1df33554382a09aaca4879e4857f42b91ca3bbc6 (diff) | |
download | rtmux-1270f8fed8642ac61d14be6a3aeb8d002db82a78.tar.gz rtmux-1270f8fed8642ac61d14be6a3aeb8d002db82a78.tar.bz2 rtmux-1270f8fed8642ac61d14be6a3aeb8d002db82a78.zip |
Check if the index is in use and fail before creating the child process,
rather than leaving a stray child on failure.
Diffstat (limited to 'window.c')
-rw-r--r-- | window.c | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -123,7 +123,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; @@ -135,15 +135,19 @@ 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) { struct window *w = wl->window; @@ -153,11 +157,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 * |