screen_end can be called multiple times for the same screen.

Work around segfault in TAILQ_REMOVE by abusing the tqe_prev pointer
as a flag that identifies an already removed node.

This should really be solved by calling screen_end only once or by
keeping state explicitely in the screen structure.
This commit is contained in:
mlelstv 2014-01-06 07:56:47 +00:00
parent d2ad8298ea
commit 99a38adeb5

View File

@ -1,4 +1,4 @@
/* $NetBSD: screen.c,v 1.6 2013/12/01 21:48:33 christos Exp $ */
/* $NetBSD: screen.c,v 1.7 2014/01/06 07:56:47 mlelstv Exp $ */
/*-
* Copyright (c) 1993, 1994
* The Regents of the University of California. All rights reserved.
@ -139,9 +139,14 @@ screen_end1(SCR *sp, int init)
*
* If a created screen failed during initialization, it may not
* be linked into the chain.
*
* XXX screen_end can be called multiple times, abuse the tqe_prev pointer
* to signal wether the tailq node is on-list.
*/
if (init)
if (init && sp->q.tqe_prev) {
TAILQ_REMOVE(&sp->wp->scrq, sp, q);
sp->q.tqe_prev = NULL;
}
/* The screen is no longer real. */
F_CLR(sp, SC_SCR_EX | SC_SCR_VI);