Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/nvi/dist/common screen_end can be called multip...



details:   https://anonhg.NetBSD.org/src/rev/0be8d452142c
branches:  trunk
changeset: 325776:0be8d452142c
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Mon Jan 06 07:56:47 2014 +0000

description:
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.

diffstat:

 external/bsd/nvi/dist/common/screen.c |  9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diffs (25 lines):

diff -r dec543777ad7 -r 0be8d452142c external/bsd/nvi/dist/common/screen.c
--- a/external/bsd/nvi/dist/common/screen.c     Sun Jan 05 21:38:25 2014 +0000
+++ b/external/bsd/nvi/dist/common/screen.c     Mon Jan 06 07:56:47 2014 +0000
@@ -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 @@
         *
         * 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);



Home | Main Index | Thread Index | Old Index