diff options
author | Tiago Cunha <tcunha@gmx.com> | 2011-02-15 15:09:52 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2011-02-15 15:09:52 +0000 |
commit | 4e4568cade9c54f02b0f41d9372f4124f1fb54be (patch) | |
tree | d139a54b7d0b9606f098773ec01d52ebadd361f7 /window.c | |
parent | d0d1c0e486dc13b6e5db93819ca1b634d384f283 (diff) | |
download | rtmux-4e4568cade9c54f02b0f41d9372f4124f1fb54be.tar.gz rtmux-4e4568cade9c54f02b0f41d9372f4124f1fb54be.tar.bz2 rtmux-4e4568cade9c54f02b0f41d9372f4124f1fb54be.zip |
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.
Diffstat (limited to 'window.c')
-rw-r--r-- | window.c | 26 |
1 files changed, 16 insertions, 10 deletions
@@ -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,15 +132,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; @@ -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 * |