bug-ncurses
[Top][All Lists]
Advanced

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

Re: bug found when freeing screen(s)


From: Thomas Dickey
Subject: Re: bug found when freeing screen(s)
Date: Fri, 17 Sep 2010 04:49:29 -0400
User-agent: Mutt/1.5.20 (2009-06-14)

On Fri, Sep 17, 2010 at 10:27:19AM +0200, Frédéric Boiteux wrote:
>     Hello,
> 
> When porting an own application using ncurses from an old 5.5 version to
> a current 5.7 (from Debian Lenny system), I found a bug related to free
> of screens (the application manages multiple terminals) : when the close
> of terminals was in the same order they was created, the application
> segfaulted or looped indefinitely. I identified the bug in the
> delscreen() function, and more precisely in delink_screen() where the
> global list of screens is incorrectly updated.
>   I've successfully tested my application with the simple patch attached.
> 
>   I think the bug is already present in latest version of ncurses.

The current code has this fix, from 2010/4/24:

   fix warnings from clang --analyze
   (this was a coding error)

--- lib_set_term.c      2010/04/24 23:09:24     1.136 
+++ lib_set_term.c      2010/05/01 19:47:51     1.137 
@@ -47,7 +47,7 @@ 
 #define CUR SP_TERMTYPE
 #endif

-MODULE_ID("$Id: lib_set_term.c,v 1.135 2009/11/28 21:49:24 tom Exp $") 
+MODULE_ID("$Id: lib_set_term.c,v 1.136 2010/04/24 23:09:24 tom Exp $") 

 #ifdef USE_TERM_DRIVER
 #define MaxColors      InfoOf(sp).maxcolors
@@ -117,7 +117,7 @@ 
     for (each_screen(temp)) {
        if (temp == sp) {
            if (last)
-               last = sp->_next_screen; 
+               last->_next_screen = sp->_next_screen; 
            else
                _nc_screen_chain = sp->_next_screen;
            result = TRUE;


> 
>   Could you validate my analyze and proposed resolution ?
> 
>      with regards,
>         Fred
> 

> diff -Naur ncurses-5.7+20081213/ncurses/base/lib_set_term.c 
> ncurses-5.7+20081213mod/ncurses/base/lib_set_term.c
> --- ncurses-5.7+20081213/ncurses/base/lib_set_term.c  2008-08-04 
> 20:11:12.000000000 +0200
> +++ ncurses-5.7+20081213mod/ncurses/base/lib_set_term.c       2010-09-16 
> 16:38:18.000000000 +0200
> @@ -106,9 +106,9 @@
>      for (each_screen(temp)) {
>       if (temp == sp) {
>           if (last)
> -             last = sp->_next_screen;
> +             last->_next_screen = sp->_next_screen;
>           else
> -             _nc_screen_chain = sp->_next_screen;
> +             _nc_screen_chain   = sp->_next_screen;
>           result = TRUE;
>           break;
>       }

> _______________________________________________
> Bug-ncurses mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/bug-ncurses


-- 
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]