From: Thomas E. Dickey Date: Sun, 26 Mar 2017 01:21:31 +0000 (+0000) Subject: ncurses 6.0 - patch 20170325 X-Git-Tag: v6.1~44 X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=commitdiff_plain;h=2e68dc325852af56f2ec6c315b323a4f9c3d62c9 ncurses 6.0 - patch 20170325 + fix a memory leak in the window-list when creating multiple screens (reports by Andres Martinelli, Debian #783486). + reviewed calls from link_test.c, added a few more null-pointer checks. + add a null-pointer check in ungetmouse, in case mousemask was not called (report by "Kau"). + updated curs_sp_funcs.3x for new functions. --- diff --git a/NEWS b/NEWS index ef4cabd2..01b809ce 100644 --- a/NEWS +++ b/NEWS @@ -25,7 +25,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: NEWS,v 1.2779 2017/03/18 19:17:44 tom Exp $ +-- $Id: NEWS,v 1.2782 2017/03/25 23:37:12 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,15 @@ See the AUTHORS file for the corresponding full names. Changes through 1.9.9e did not credit all contributions; it is not possible to add this information. +20170325 + + fix a memory leak in the window-list when creating multiple screens + (reports by Andres Martinelli, Debian #783486). + + reviewed calls from link_test.c, added a few more null-pointer + checks. + + add a null-pointer check in ungetmouse, in case mousemask was not + called (report by "Kau"). + + updated curs_sp_funcs.3x for new functions. + 20170318 + change TERMINAL structure in term.h to make it opaque. Some applications misuse its members, e.g., directly modifying it diff --git a/VERSION b/VERSION index 977c7749..224a8e1f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5:0:9 6.0 20170318 +5:0:9 6.0 20170325 diff --git a/dist.mk b/dist.mk index cbf01923..239e3227 100644 --- a/dist.mk +++ b/dist.mk @@ -25,7 +25,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: dist.mk,v 1.1152 2017/03/12 09:25:40 tom Exp $ +# $Id: dist.mk,v 1.1153 2017/03/19 00:59:07 tom Exp $ # Makefile for creating ncurses distributions. # # This only needs to be used directly as a makefile by developers, but @@ -37,7 +37,7 @@ SHELL = /bin/sh # These define the major/minor/patch versions of ncurses. NCURSES_MAJOR = 6 NCURSES_MINOR = 0 -NCURSES_PATCH = 20170318 +NCURSES_PATCH = 20170325 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/include/curses.wide b/include/curses.wide index 5d130a96..58ccd150 100644 --- a/include/curses.wide +++ b/include/curses.wide @@ -1,4 +1,4 @@ -/* $Id: curses.wide,v 1.46 2014/02/01 22:00:32 tom Exp $ */ +/* $Id: curses.wide,v 1.49 2017/03/26 00:04:04 tom Exp $ */ /* * vile:cmode: * This file is part of ncurses, designed to be appended after curses.h.in @@ -261,7 +261,7 @@ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_puts) (SCREEN*, attr_t, NCURSES_P #define wins_wstr(w,t) wins_nwstr((w),(t),-1) #if !NCURSES_OPAQUE -#define wgetbkgrnd(win,wch) ((win) ? (*(wch) = (win)->_bkgrnd) : *(wch), OK) +#define wgetbkgrnd(win,wch) ((0 != (const void*)(wch)) ? ((win) ? (*(wch) = (win)->_bkgrnd) : *(wch), OK) : ERR) #endif #define mvadd_wch(y,x,c) mvwadd_wch(stdscr,(y),(x),(c)) diff --git a/man/curs_bkgrnd.3x b/man/curs_bkgrnd.3x index 2bbb4fce..f9b4f419 100644 --- a/man/curs_bkgrnd.3x +++ b/man/curs_bkgrnd.3x @@ -1,5 +1,5 @@ .\"*************************************************************************** -.\" Copyright (c) 2002-2012,2015 Free Software Foundation, Inc. * +.\" Copyright (c) 2002-2015,2017 Free Software Foundation, Inc. * .\" * .\" Permission is hereby granted, free of charge, to any person obtaining a * .\" copy of this software and associated documentation files (the * @@ -26,7 +26,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: curs_bkgrnd.3x,v 1.6 2015/07/21 00:18:42 tom Exp $ +.\" $Id: curs_bkgrnd.3x,v 1.7 2017/03/25 21:49:00 tom Exp $ .de bP .IP \(bu 4 .. @@ -87,6 +87,8 @@ appears, it is changed to the new background character. .PP The \fBgetbkgrnd\fR function returns the given window's current background character/attribute pair via the \fBwch\fR pointer. +If the given window pointer is null, +the character is not updated (but no error returned). .SH NOTES Note that \fBbkgrnd\fR, @@ -98,8 +100,11 @@ may be macros. The \fBbkgrndset\fR and \fBwbkgrndset\fR routines do not return a value. .PP Upon successful completion, the other functions return \fBOK\fR. -Otherwise, they return \fBERR\fR. +Otherwise, they return \fBERR\fR: +.bP A null window pointer is treated as an error. +.bP +A null character pointer is treated as an error. .SH SEE ALSO \fBcurses\fR(3X), \fBcurs_bkgd\fR(3X) diff --git a/man/curs_sp_funcs.3x b/man/curs_sp_funcs.3x index bb490591..f7369762 100644 --- a/man/curs_sp_funcs.3x +++ b/man/curs_sp_funcs.3x @@ -1,5 +1,5 @@ .\"*************************************************************************** -.\" Copyright (c) 2010-2013,2015 Free Software Foundation, Inc. * +.\" Copyright (c) 2010-2015,2017 Free Software Foundation, Inc. * .\" * .\" Permission is hereby granted, free of charge, to any person obtaining a * .\" copy of this software and associated documentation files (the * @@ -26,7 +26,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: curs_sp_funcs.3x,v 1.7 2015/12/05 20:33:14 tom Exp $ +.\" $Id: curs_sp_funcs.3x,v 1.8 2017/03/25 18:08:33 tom Exp $ .TH curs_sp_funcs 3X "" .na .hy 0 @@ -38,6 +38,8 @@ curs_sp_funcs \- \fBcurses\fR screen-pointer extension \fB#include \fR .nf .sp +\fBint alloc_pair_sp(SCREEN*, int, int);\fR +.br \fBint assume_default_colors_sp(SCREEN*, int, int);\fR .br \fBint baudrate_sp(SCREEN*);\fR @@ -70,6 +72,10 @@ curs_sp_funcs \- \fBcurses\fR screen-pointer extension .br \fBint filter_sp(SCREEN*);\fR .br +\fBint find_pair_sp(SCREEN*, int, int);\fR +.br +\fBint free_pair_sp(SCREEN*, int);\fR +.br \fBint flash_sp(SCREEN*);\fR .br \fBint flushinp_sp(SCREEN*);\fR @@ -112,6 +118,8 @@ curs_sp_funcs \- \fBcurses\fR screen-pointer extension .br \fBchar killchar_sp(SCREEN*);\fR .br +\fBchar* longname_sp(SCREEN*);\fR +.br \fBint mcprint_sp(SCREEN*, char *, int);\fR .br \fBint mouseinterval_sp(SCREEN*, int);\fR @@ -228,6 +236,8 @@ curs_sp_funcs \- \fBcurses\fR screen-pointer extension .br \fBvoid use_env_sp(SCREEN*, bool);\fR .br +\fBvoid use_tioctl_sp (SCREEN *, bool)\fR +.br \fBint use_legacy_coding_sp(SCREEN*, int);\fR .br \fBint vid_attr_sp(SCREEN*, attr_t, short, void *);\fR diff --git a/ncurses/base/lib_addstr.c b/ncurses/base/lib_addstr.c index 6779f3f8..9038706f 100644 --- a/ncurses/base/lib_addstr.c +++ b/ncurses/base/lib_addstr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2011,2016 Free Software Foundation, Inc. * + * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -44,7 +44,7 @@ #include -MODULE_ID("$Id: lib_addstr.c,v 1.53 2016/01/16 21:00:53 tom Exp $") +MODULE_ID("$Id: lib_addstr.c,v 1.54 2017/03/25 21:10:03 tom Exp $") NCURSES_EXPORT(int) waddnstr(WINDOW *win, const char *astr, int n) @@ -87,7 +87,7 @@ waddchnstr(WINDOW *win, const chtype *astr, int n) T((T_CALLED("waddchnstr(%p,%p,%d)"), (void *) win, (const void *) astr, n)); - if (!win) + if (!win || !astr) returnCode(ERR); y = win->_cury; diff --git a/ncurses/base/lib_dft_fgbg.c b/ncurses/base/lib_dft_fgbg.c index 0e6f9417..d5fd1a03 100644 --- a/ncurses/base/lib_dft_fgbg.c +++ b/ncurses/base/lib_dft_fgbg.c @@ -37,7 +37,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_dft_fgbg.c,v 1.28 2017/03/01 00:09:42 tom Exp $") +MODULE_ID("$Id: lib_dft_fgbg.c,v 1.29 2017/03/25 21:00:49 tom Exp $") /* * Modify the behavior of color-pair 0 so that the library doesn't assume that @@ -68,26 +68,27 @@ NCURSES_SP_NAME(assume_default_colors) (NCURSES_SP_DCLx int fg, int bg) int code = ERR; T((T_CALLED("assume_default_colors(%p,%d,%d)"), (void *) SP_PARM, fg, bg)); + if (SP_PARM != 0) { #ifdef USE_TERM_DRIVER - if (sp != 0) - code = CallDriver_2(sp, td_defaultcolors, fg, bg); + code = CallDriver_2(SP_PARM, td_defaultcolors, fg, bg); #else - if ((orig_pair || orig_colors) && !initialize_pair) { + if ((orig_pair || orig_colors) && !initialize_pair) { - SP_PARM->_default_color = isDefaultColor(fg) || isDefaultColor(bg); - SP_PARM->_has_sgr_39_49 = (tigetflag("AX") == TRUE); - SP_PARM->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : fg; - SP_PARM->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : bg; - if (SP_PARM->_color_pairs != 0) { - bool save = SP_PARM->_default_color; - SP_PARM->_assumed_color = TRUE; - SP_PARM->_default_color = TRUE; - init_pair(0, (short) fg, (short) bg); - SP_PARM->_default_color = save; + SP_PARM->_default_color = isDefaultColor(fg) || isDefaultColor(bg); + SP_PARM->_has_sgr_39_49 = (tigetflag("AX") == TRUE); + SP_PARM->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : fg; + SP_PARM->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : bg; + if (SP_PARM->_color_pairs != 0) { + bool save = SP_PARM->_default_color; + SP_PARM->_assumed_color = TRUE; + SP_PARM->_default_color = TRUE; + init_pair(0, (short) fg, (short) bg); + SP_PARM->_default_color = save; + } + code = OK; } - code = OK; - } #endif + } returnCode(code); } diff --git a/ncurses/base/lib_freeall.c b/ncurses/base/lib_freeall.c index 8a13b407..65c77aac 100644 --- a/ncurses/base/lib_freeall.c +++ b/ncurses/base/lib_freeall.c @@ -39,7 +39,7 @@ extern int malloc_errfd; /* FIXME */ #endif -MODULE_ID("$Id: lib_freeall.c,v 1.65 2017/03/04 00:12:23 tom Exp $") +MODULE_ID("$Id: lib_freeall.c,v 1.66 2017/03/25 22:59:38 tom Exp $") /* * Free all ncurses data. This is used for testing only (there's no practical @@ -76,8 +76,19 @@ NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0) WINDOW *p_win = &(p->win); bool found = FALSE; +#ifndef USE_SP_WINDOWLIST + if (p->screen != SP_PARM) + continue; +#endif + for (each_window(SP_PARM, q)) { WINDOW *q_win = &(q->win); + +#ifndef USE_SP_WINDOWLIST + if (q->screen != SP_PARM) + continue; +#endif + if ((p != q) && (q_win->_flags & _SUBWIN) && (p_win == q_win->_parent)) { diff --git a/ncurses/base/lib_getstr.c b/ncurses/base/lib_getstr.c index 0e446349..fecb3e70 100644 --- a/ncurses/base/lib_getstr.c +++ b/ncurses/base/lib_getstr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2009,2011 Free Software Foundation, Inc. * + * Copyright (c) 1998-2011,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -40,7 +40,7 @@ #include -MODULE_ID("$Id: lib_getstr.c,v 1.30 2011/10/22 16:31:35 tom Exp $") +MODULE_ID("$Id: lib_getstr.c,v 1.31 2017/03/25 21:09:51 tom Exp $") /* * This wipes out the last character, no matter whether it was a tab, control @@ -85,7 +85,7 @@ wgetnstr_events(WINDOW *win, T((T_CALLED("wgetnstr(%p,%p,%d)"), (void *) win, (void *) str, maxlen)); - if (!win) + if (!win || !str) returnCode(ERR); NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_ARGx &buf); diff --git a/ncurses/base/lib_mouse.c b/ncurses/base/lib_mouse.c index 43b0069a..e6976349 100644 --- a/ncurses/base/lib_mouse.c +++ b/ncurses/base/lib_mouse.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2015,2016 Free Software Foundation, Inc. * + * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -84,7 +84,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_mouse.c,v 1.170 2016/09/10 18:36:08 tom Exp $") +MODULE_ID("$Id: lib_mouse.c,v 1.171 2017/03/25 21:20:35 tom Exp $") #include @@ -1746,11 +1746,14 @@ NCURSES_EXPORT(int) NCURSES_SP_NAME(getmouse) (NCURSES_SP_DCLx MEVENT * aevent) { int result = ERR; + MEVENT *eventp; T((T_CALLED("getmouse(%p,%p)"), (void *) SP_PARM, (void *) aevent)); - if ((aevent != 0) && (SP_PARM != 0) && (SP_PARM->_mouse_type != M_NONE)) { - MEVENT *eventp = SP_PARM->_mouse_eventp; + if ((aevent != 0) && + (SP_PARM != 0) && + (SP_PARM->_mouse_type != M_NONE) && + (eventp = SP_PARM->_mouse_eventp) != 0) { /* compute the current-event pointer */ MEVENT *prev = PREV(eventp); @@ -1799,11 +1802,13 @@ NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetmouse) (NCURSES_SP_DCLx MEVENT * aevent) { int result = ERR; + MEVENT *eventp; T((T_CALLED("ungetmouse(%p,%p)"), (void *) SP_PARM, (void *) aevent)); - if (aevent != 0 && SP_PARM != 0) { - MEVENT *eventp = SP_PARM->_mouse_eventp; + if (aevent != 0 && + SP_PARM != 0 && + (eventp = SP_PARM->_mouse_eventp) != 0) { /* stick the given event in the next-free slot */ *eventp = *aevent; diff --git a/ncurses/base/lib_newwin.c b/ncurses/base/lib_newwin.c index 564c07fb..262454eb 100644 --- a/ncurses/base/lib_newwin.c +++ b/ncurses/base/lib_newwin.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2011,2016 Free Software Foundation, Inc. * + * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -43,7 +43,7 @@ #include #include -MODULE_ID("$Id: lib_newwin.c,v 1.72 2016/05/28 23:11:26 tom Exp $") +MODULE_ID("$Id: lib_newwin.c,v 1.73 2017/03/25 23:33:03 tom Exp $") #define window_is(name) ((sp)->_##name == win) @@ -104,12 +104,12 @@ _nc_freewin(WINDOW *win) WINDOWLIST *p, *q; q = 0; - for (each_window(SP_PARM, p)) { + for (each_window(sp, p)) { if (&(p->win) == win) { remove_window_from_screen(win); if (q == 0) - WindowList(SP_PARM) = p->next; + WindowList(sp) = p->next; else q->next = p->next; diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index 0285c539..851d7bb2 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -34,7 +34,7 @@ ****************************************************************************/ /* - * $Id: curses.priv.h,v 1.563 2017/03/10 09:21:46 tom Exp $ + * $Id: curses.priv.h,v 1.564 2017/03/25 23:26:05 tom Exp $ * * curses.priv.h * @@ -1288,6 +1288,12 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; #define WINDOW_EXT(w,m) (((WINDOWLIST *)((void *)((char *)(w) - offsetof(WINDOWLIST, win))))->m) +#ifdef USE_SP_WINDOWLIST +#define SP_INIT_WINDOWLIST(sp) WindowList(sp) = 0 +#else +#define SP_INIT_WINDOWLIST(sp) /* nothing */ +#endif + #define SP_PRE_INIT(sp) \ sp->_cursrow = -1; \ sp->_curscol = -1; \ @@ -1298,7 +1304,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; sp->_fifohead = -1; \ sp->_endwin = TRUE; \ sp->_cursor = -1; \ - WindowList(sp) = 0; \ + SP_INIT_WINDOWLIST(sp); \ sp->_outch = NCURSES_OUTC_FUNC; \ sp->jump = 0 \ diff --git a/package/debian-mingw/changelog b/package/debian-mingw/changelog index 0de6a4da..894d091d 100644 --- a/package/debian-mingw/changelog +++ b/package/debian-mingw/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.0+20170318) unstable; urgency=low +ncurses6 (6.0+20170325) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sun, 12 Mar 2017 05:25:40 -0400 + -- Thomas E. Dickey Sat, 18 Mar 2017 20:59:07 -0400 ncurses6 (5.9-20131005) unstable; urgency=low diff --git a/package/debian-mingw64/changelog b/package/debian-mingw64/changelog index 0de6a4da..894d091d 100644 --- a/package/debian-mingw64/changelog +++ b/package/debian-mingw64/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.0+20170318) unstable; urgency=low +ncurses6 (6.0+20170325) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sun, 12 Mar 2017 05:25:40 -0400 + -- Thomas E. Dickey Sat, 18 Mar 2017 20:59:07 -0400 ncurses6 (5.9-20131005) unstable; urgency=low diff --git a/package/debian/changelog b/package/debian/changelog index ea3a2997..7c33c3a1 100644 --- a/package/debian/changelog +++ b/package/debian/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.0+20170318) unstable; urgency=low +ncurses6 (6.0+20170325) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sun, 12 Mar 2017 05:25:40 -0400 + -- Thomas E. Dickey Sat, 18 Mar 2017 20:59:07 -0400 ncurses6 (5.9-20120608) unstable; urgency=low diff --git a/package/mingw-ncurses.nsi b/package/mingw-ncurses.nsi index b2b3acbb..b1bb10d2 100644 --- a/package/mingw-ncurses.nsi +++ b/package/mingw-ncurses.nsi @@ -1,4 +1,4 @@ -; $Id: mingw-ncurses.nsi,v 1.203 2017/03/12 09:25:40 tom Exp $ +; $Id: mingw-ncurses.nsi,v 1.204 2017/03/19 00:59:07 tom Exp $ ; TODO add examples ; TODO bump ABI to 6 @@ -10,7 +10,7 @@ !define VERSION_MAJOR "6" !define VERSION_MINOR "0" !define VERSION_YYYY "2017" -!define VERSION_MMDD "0318" +!define VERSION_MMDD "0325" !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD} !define MY_ABI "5" diff --git a/package/mingw-ncurses.spec b/package/mingw-ncurses.spec index 22f17266..3e034601 100644 --- a/package/mingw-ncurses.spec +++ b/package/mingw-ncurses.spec @@ -3,7 +3,7 @@ Summary: shared libraries for terminal handling Name: mingw32-ncurses6 Version: 6.0 -Release: 20170318 +Release: 20170325 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/package/ncurses.spec b/package/ncurses.spec index 6156636c..54c238b2 100644 --- a/package/ncurses.spec +++ b/package/ncurses.spec @@ -1,7 +1,7 @@ Summary: shared libraries for terminal handling Name: ncurses6 Version: 6.0 -Release: 20170318 +Release: 20170325 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz