From: Thomas E. Dickey Date: Sun, 18 Nov 2012 02:58:41 +0000 (+0000) Subject: ncurses 5.9 - patch 20121117 X-Git-Tag: v6.0~128 X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=commitdiff_plain;h=98d8891f42d8acac5c2ade39d163f386057a22e4;hp=da2e96ef7073a13477fe57144926dd159e6089c0;ds=sidebyside ncurses 5.9 - patch 20121117 > fixes based on Coverity report: + add missing braces around FreeAndNull in two places. + various fixes in test/ncurses.c + improve limit-checks in tinfo/make_hash.c, tinfo/read_entry.c + correct malloc size in progs/infocmp.c + guard against negative array indices in test/knight.c + fix off-by-one limit check in test/color_name.h + add null-pointer check in progs/tabs.c, test/bs.c, test/demo_forms.c, test/inchs.c + fix memory-leak in tinfo/lib_setup.c, progs/toe.c, test/clip_printw.c, test/demo_menus.c + delete unused windows in test/chgat.c, test/clip_printw.c, test/insdelln.c, test/newdemo.c on error-return. --- diff --git a/NEWS b/NEWS index b3d48e93..5245e26b 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.1973 2012/11/10 21:44:29 tom Exp $ +-- $Id: NEWS,v 1.1974 2012/11/18 02:16:21 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,21 @@ 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. +20121117 + > fixes based on Coverity report: + + add missing braces around FreeAndNull in two places. + + various fixes in test/ncurses.c + + improve limit-checks in tinfo/make_hash.c, tinfo/read_entry.c + + correct malloc size in progs/infocmp.c + + guard against negative array indices in test/knight.c + + fix off-by-one limit check in test/color_name.h + + add null-pointer check in progs/tabs.c, test/bs.c, test/demo_forms.c, + test/inchs.c + + fix memory-leak in tinfo/lib_setup.c, progs/toe.c, + test/clip_printw.c, test/demo_menus.c + + delete unused windows in test/chgat.c, test/clip_printw.c, + test/insdelln.c, test/newdemo.c on error-return. + 20121110 + modify configure macro CF_INCLUDE_DIRS to put $CPPFLAGS after the local -I include options in case someone has set conflicting -I diff --git a/dist.mk b/dist.mk index 92767c29..66aecea0 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.900 2012/11/10 21:02:17 tom Exp $ +# $Id: dist.mk,v 1.901 2012/11/17 16:48:42 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 = 5 NCURSES_MINOR = 9 -NCURSES_PATCH = 20121110 +NCURSES_PATCH = 20121117 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/ncurses/base/keyok.c b/ncurses/base/keyok.c index 6127fd27..00e936da 100644 --- a/ncurses/base/keyok.c +++ b/ncurses/base/keyok.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2009,2011 Free Software Foundation, Inc. * + * Copyright (c) 1998-2011,2012 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 * @@ -33,7 +33,7 @@ #include -MODULE_ID("$Id: keyok.c,v 1.12 2011/10/22 17:03:22 tom Exp $") +MODULE_ID("$Id: keyok.c,v 1.13 2012/11/18 02:14:35 tom Exp $") /* * Enable (or disable) ncurses' interpretation of a keycode by adding (or @@ -63,23 +63,29 @@ NCURSES_SP_NAME(keyok) (NCURSES_SP_DCLx int c, bool flag) if (flag) { while ((s = _nc_expand_try(SP_PARM->_key_ok, - ch, &count, (size_t) 0)) != 0 - && _nc_remove_key(&(SP_PARM->_key_ok), ch)) { - code = _nc_add_to_try(&(SP_PARM->_keytry), s, ch); - free(s); - count = 0; - if (code != OK) - break; + ch, &count, (size_t) 0)) != 0) { + if (_nc_remove_key(&(SP_PARM->_key_ok), ch)) { + code = _nc_add_to_try(&(SP_PARM->_keytry), s, ch); + free(s); + count = 0; + if (code != OK) + break; + } else { + free(s); + } } } else { while ((s = _nc_expand_try(SP_PARM->_keytry, - ch, &count, (size_t) 0)) != 0 - && _nc_remove_key(&(SP_PARM->_keytry), ch)) { - code = _nc_add_to_try(&(SP_PARM->_key_ok), s, ch); - free(s); - count = 0; - if (code != OK) - break; + ch, &count, (size_t) 0)) != 0) { + if (_nc_remove_key(&(SP_PARM->_keytry), ch)) { + code = _nc_add_to_try(&(SP_PARM->_key_ok), s, ch); + free(s); + count = 0; + if (code != OK) + break; + } else { + free(s); + } } } } diff --git a/ncurses/base/lib_freeall.c b/ncurses/base/lib_freeall.c index 38d73aa2..03137492 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.61 2012/08/25 19:52:47 tom Exp $") +MODULE_ID("$Id: lib_freeall.c,v 1.62 2012/11/17 23:53:03 tom Exp $") /* * Free all ncurses data. This is used for testing only (there's no practical @@ -70,19 +70,21 @@ NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0) /* Delete only windows that're not a parent */ for (each_window(SP_PARM, p)) { + WINDOW *p_win = &(p->win); bool found = FALSE; for (each_window(SP_PARM, q)) { + WINDOW *q_win = &(q->win); if ((p != q) - && (q->win._flags & _SUBWIN) - && (&(p->win) == q->win._parent)) { + && (q_win->_flags & _SUBWIN) + && (p_win == q_win->_parent)) { found = TRUE; break; } } if (!found) { - if (delwin(&(p->win)) != ERR) + if (delwin(p_win) != ERR) deleted = TRUE; break; } diff --git a/ncurses/tinfo/lib_cur_term.c b/ncurses/tinfo/lib_cur_term.c index 86e130e7..c67e1631 100644 --- a/ncurses/tinfo/lib_cur_term.c +++ b/ncurses/tinfo/lib_cur_term.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. * + * Copyright (c) 1998-2010,2012 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 * @@ -39,7 +39,7 @@ #include #include /* ospeed */ -MODULE_ID("$Id: lib_cur_term.c,v 1.30 2010/12/19 01:38:45 tom Exp $") +MODULE_ID("$Id: lib_cur_term.c,v 1.31 2012/11/18 02:12:43 tom Exp $") #undef CUR #define CUR termp->type. @@ -148,8 +148,9 @@ NCURSES_SP_NAME(del_curterm) (NCURSES_SP_DCLx TERMINAL * termp) FreeIfNeeded(termp->_termname); #if USE_HOME_TERMINFO - if (_nc_globals.home_terminfo != 0) + if (_nc_globals.home_terminfo != 0) { FreeAndNull(_nc_globals.home_terminfo); + } #endif #ifdef USE_TERM_DRIVER if (TCB->drv) diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c index 60ce2c68..83742d5b 100644 --- a/ncurses/tinfo/lib_setup.c +++ b/ncurses/tinfo/lib_setup.c @@ -48,7 +48,7 @@ #include #endif -MODULE_ID("$Id: lib_setup.c,v 1.150 2012/09/22 18:46:12 tom Exp $") +MODULE_ID("$Id: lib_setup.c,v 1.151 2012/11/18 00:24:56 tom Exp $") /**************************************************************************** * @@ -781,11 +781,14 @@ TINFO_SETUP_TERM(TERMINAL ** tp, if ((VALID_STRING(cursor_address) || (VALID_STRING(cursor_down) && VALID_STRING(cursor_home))) && VALID_STRING(clear_screen)) { + free(termp); ret_error1(TGETENT_YES, "terminal is not really generic.\n", tname); } else { + free(termp); ret_error1(TGETENT_NO, "I need something more specific.\n", tname); } } else if (hard_copy) { + free(termp); ret_error1(TGETENT_YES, "I can't handle hardcopy terminals.\n", tname); } #endif diff --git a/ncurses/tinfo/make_hash.c b/ncurses/tinfo/make_hash.c index 8fb2538c..99e4bd4f 100644 --- a/ncurses/tinfo/make_hash.c +++ b/ncurses/tinfo/make_hash.c @@ -44,7 +44,7 @@ #include -MODULE_ID("$Id: make_hash.c,v 1.8 2012/02/22 22:40:24 tom Exp $") +MODULE_ID("$Id: make_hash.c,v 1.9 2012/11/18 01:30:03 tom Exp $") /* * _nc_make_hash_table() @@ -119,6 +119,18 @@ _nc_make_hash_table(struct name_table_entry *table, #define MAX_COLUMNS BUFSIZ /* this _has_ to be worst-case */ +static int +count_columns(char **list) +{ + int result = 0; + if (list != 0) { + while (*list++) { + ++result; + } + } + return result; +} + static char ** parse_columns(char *buffer) { @@ -201,6 +213,13 @@ main(int argc, char **argv) list = parse_columns(buffer); if (list == 0) /* blank or comment */ continue; + if (column > count_columns(list)) { + fprintf(stderr, "expected %d columns, have %d:\n%s\n", + column, + count_columns(list), + buffer); + exit(EXIT_FAILURE); + } name_table[n].nte_link = -1; /* end-of-hash */ name_table[n].nte_name = strdup(list[column]); if (!strcmp(list[2], "bool")) { diff --git a/ncurses/tinfo/name_match.c b/ncurses/tinfo/name_match.c index fccd2649..a4433bc9 100644 --- a/ncurses/tinfo/name_match.c +++ b/ncurses/tinfo/name_match.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1999-2008,2011 Free Software Foundation, Inc. * + * Copyright (c) 1999-2011,2012 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 * @@ -33,7 +33,7 @@ #include #include -MODULE_ID("$Id: name_match.c,v 1.21 2011/08/13 20:23:12 tom Exp $") +MODULE_ID("$Id: name_match.c,v 1.22 2012/11/18 02:10:17 tom Exp $") #define FirstName _nc_globals.first_name @@ -62,8 +62,9 @@ _nc_first_name(const char *const sp) #if NO_LEAKS if (sp == 0) { - if (FirstName != 0) + if (FirstName != 0) { FreeAndNull(FirstName); + } } else #endif { diff --git a/ncurses/tinfo/read_entry.c b/ncurses/tinfo/read_entry.c index a14bad68..47852ad1 100644 --- a/ncurses/tinfo/read_entry.c +++ b/ncurses/tinfo/read_entry.c @@ -41,7 +41,7 @@ #include -MODULE_ID("$Id: read_entry.c,v 1.120 2012/10/27 21:51:07 tom Exp $") +MODULE_ID("$Id: read_entry.c,v 1.121 2012/11/18 01:18:47 tom Exp $") #define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts)) @@ -279,6 +279,8 @@ _nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit) } TR(TRACE_DATABASE, ("READ extended-offsets @%d", offset)); + if ((unsigned) (ext_str_count + (int) need) >= (MAX_ENTRY_SIZE / 2)) + return (TGETENT_NO); if ((ext_str_count || need) && !read_shorts(buf, ext_str_count + (int) need)) return (TGETENT_NO); @@ -315,7 +317,7 @@ _nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit) } if (need) { - if (ext_str_count >= (MAX_ENTRY_SIZE * 2)) + if (ext_str_count >= (MAX_ENTRY_SIZE / 2)) return (TGETENT_NO); if ((ptr->ext_Names = TYPE_CALLOC(char *, need)) == 0) return (TGETENT_NO); diff --git a/package/debian/changelog b/package/debian/changelog index bcc4a375..2fb230dc 100644 --- a/package/debian/changelog +++ b/package/debian/changelog @@ -1,8 +1,8 @@ -ncurses6 (5.9-20121110) unstable; urgency=low +ncurses6 (5.9-20121117) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 10 Nov 2012 16:02:42 -0500 + -- Thomas E. Dickey Sat, 17 Nov 2012 11:58:08 -0500 ncurses6 (5.9-20120608) unstable; urgency=low diff --git a/package/ncurses.spec b/package/ncurses.spec index 35f69bc5..d7b6901b 100644 --- a/package/ncurses.spec +++ b/package/ncurses.spec @@ -1,7 +1,7 @@ Summary: shared libraries for terminal handling Name: ncurses6 Release: 5.9 -Version: 20121110 +Version: 20121117 License: X11 Group: Development/Libraries Source: ncurses-%{release}-%{version}.tgz diff --git a/progs/infocmp.c b/progs/infocmp.c index 6311a089..506a374e 100644 --- a/progs/infocmp.c +++ b/progs/infocmp.c @@ -42,7 +42,7 @@ #include -MODULE_ID("$Id: infocmp.c,v 1.122 2012/10/27 19:50:50 tom Exp $") +MODULE_ID("$Id: infocmp.c,v 1.123 2012/11/17 23:15:10 tom Exp $") #define L_CURL "{" #define R_CURL "}" @@ -1220,7 +1220,7 @@ any_initializer(const char *fmt, const char *type) need = (strlen(entries->tterm.term_names) + strlen(type) + strlen(fmt)); - initializer = (char *) malloc(need); + initializer = (char *) malloc(need + 1); if (initializer == 0) failed("any_initializer"); } diff --git a/progs/tabs.c b/progs/tabs.c index 07790f83..bded0b04 100644 --- a/progs/tabs.c +++ b/progs/tabs.c @@ -37,7 +37,7 @@ #define USE_LIBTINFO #include -MODULE_ID("$Id: tabs.c,v 1.24 2012/10/27 19:53:53 tom Exp $") +MODULE_ID("$Id: tabs.c,v 1.25 2012/11/18 01:21:47 tom Exp $") static void usage(void) GCC_NORETURN; @@ -116,22 +116,24 @@ decode_tabs(const char *tab_list) } } - /* - * If there is only one value, then it is an option such as "-8". - */ - if ((n == 0) && (value > 0)) { - int step = value; - while (n < max_cols - 1) { - result[n++] = value; - value += step; + if (result != 0) { + /* + * If there is only one value, then it is an option such as "-8". + */ + if ((n == 0) && (value > 0)) { + int step = value; + while (n < max_cols - 1) { + result[n++] = value; + value += step; + } } - } - /* - * Add the last value, if any. - */ - result[n++] = value + prior; - result[n] = 0; + /* + * Add the last value, if any. + */ + result[n++] = value + prior; + result[n] = 0; + } return result; } diff --git a/progs/toe.c b/progs/toe.c index 56c9d9fb..f60d84e8 100644 --- a/progs/toe.c +++ b/progs/toe.c @@ -44,7 +44,7 @@ #include #endif -MODULE_ID("$Id: toe.c,v 1.69 2012/10/27 20:01:20 tom Exp $") +MODULE_ID("$Id: toe.c,v 1.70 2012/11/17 23:39:42 tom Exp $") #define isDotname(name) (!strcmp(name, ".") || !strcmp(name, "..")) @@ -437,7 +437,10 @@ typelist(int eargc, char *eargv[], (void) fprintf(stderr, "%s: couldn't open terminfo file %s.\n", _nc_progname, name_2); + free(cwd_buf); free(name_2); + closedir(entrydir); + closedir(termdir); return (EXIT_FAILURE); } diff --git a/test/bs.c b/test/bs.c index 12df0934..53a4df76 100644 --- a/test/bs.c +++ b/test/bs.c @@ -34,7 +34,7 @@ * v2.0 featuring strict ANSI/POSIX conformance, November 1993. * v2.1 with ncurses mouse support, September 1995 * - * $Id: bs.c,v 1.53 2012/06/09 20:30:32 tom Exp $ + * $Id: bs.c,v 1.54 2012/11/18 00:57:48 tom Exp $ */ #include @@ -863,7 +863,9 @@ plyturn(void) m = " You'll pick up survivors from my %s, I hope...!"; break; } - (void) printw(m, ss->name); + if (m != 0) { + (void) printw(m, ss->name); + } (void) beep(); } return (hit); diff --git a/test/chgat.c b/test/chgat.c index 53ecfd7c..919b5c9e 100644 --- a/test/chgat.c +++ b/test/chgat.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2006-2009,2010 Free Software Foundation, Inc. * + * Copyright (c) 2006-2010,2012 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: chgat.c,v 1.11 2010/05/01 19:12:26 tom Exp $ + * $Id: chgat.c,v 1.12 2012/11/18 01:55:35 tom Exp $ * * test-driver for chgat/wchgat/mvchgat/mvwchgat */ @@ -176,6 +176,8 @@ do_subwindow(WINDOW *win, STATUS * sp, void func(WINDOW *)) delwin(win1); touchwin(win); } else { + if (win1 != 0) + delwin(win1); beep(); } } diff --git a/test/clip_printw.c b/test/clip_printw.c index 4009ab13..6d6d5902 100644 --- a/test/clip_printw.c +++ b/test/clip_printw.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: clip_printw.c,v 1.8 2012/06/09 20:30:32 tom Exp $ + * $Id: clip_printw.c,v 1.9 2012/11/18 00:39:48 tom Exp $ * * demonstrate how to use printw without wrapping. */ @@ -207,6 +207,8 @@ do_subwindow(WINDOW *win, STATUS * sp, void func(WINDOW *)) delwin(win1); touchwin(win); } else { + if (win1) + delwin(win1); beep(); } } @@ -337,12 +339,13 @@ test_clipping(WINDOW *win) need = (unsigned) getmaxx(win) - 1; strcpy(fmt, "%c%s%c"); } - if ((buffer = typeMalloc(char, need)) != 0) { + if ((buffer = typeMalloc(char, need + 1)) != 0) { for (j = 0; j < need; ++j) { buffer[j] = (char) ('A' + (j % 26)); } buffer[need - 1] = '\0'; st.status = clip_wprintw(win, fmt, '[', buffer, ']'); + free(buffer); } break; case 'w': diff --git a/test/color_name.h b/test/color_name.h index 0964dce1..81a3b312 100644 --- a/test/color_name.h +++ b/test/color_name.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2011 Free Software Foundation, Inc. * + * Copyright (c) 2011,2012 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: color_name.h,v 1.3 2011/05/14 17:41:17 tom Exp $ + * $Id: color_name.h,v 1.4 2012/11/18 01:59:32 tom Exp $ */ #ifndef __COLORNAME_H @@ -88,7 +88,7 @@ color_name(int color) static char temp[20]; const char *result = 0; - if (color > (int) SIZEOF(the_color_names)) { + if (color >= (int) SIZEOF(the_color_names)) { sprintf(temp, "%d", color); result = temp; } else if (color < 0) { diff --git a/test/demo_forms.c b/test/demo_forms.c index 455b7bb7..d2046946 100644 --- a/test/demo_forms.c +++ b/test/demo_forms.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: demo_forms.c,v 1.39 2012/06/09 20:30:32 tom Exp $ + * $Id: demo_forms.c,v 1.40 2012/11/18 01:22:44 tom Exp $ * * Demonstrate a variety of functions from the form library. * Thomas Dickey - 2003/4/26 @@ -153,10 +153,10 @@ display_form(FORM * f) set_form_sub(f, derwin(w, rows, cols, 1, 2)); box(w, 0, 0); keypad(w, TRUE); - } - if (post_form(f) != E_OK) - wrefresh(w); + if (post_form(f) != E_OK) + wrefresh(w); + } } static void diff --git a/test/demo_menus.c b/test/demo_menus.c index 8f19281d..dd1bd4fc 100644 --- a/test/demo_menus.c +++ b/test/demo_menus.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: demo_menus.c,v 1.36 2012/11/03 19:27:01 tom Exp $ + * $Id: demo_menus.c,v 1.37 2012/11/18 00:18:54 tom Exp $ * * Demonstrate a variety of functions from the menu library. * Thomas Dickey - 2005/4/9 @@ -269,12 +269,15 @@ menu_destroy(MENU * m) free((char *) blob); } free(items); + items = 0; } #ifdef TRACE if ((count > 0) && (m == mpTrace)) { ITEM **ip = items; - while (*ip) - free(*ip++); + if (ip != 0) { + while (*ip) + free(*ip++); + } } #endif } @@ -386,6 +389,8 @@ build_select_menu(MenuNo number, char *filename) } loaded_file = TRUE; } + if (ap == 0) + free(items); } } if (ap == 0) { diff --git a/test/inchs.c b/test/inchs.c index f07a2bda..be3aab86 100644 --- a/test/inchs.c +++ b/test/inchs.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2007,2010 Free Software Foundation, Inc. * + * Copyright (c) 2007-2010,2012 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: inchs.c,v 1.11 2010/11/13 23:41:23 tom Exp $ + * $Id: inchs.c,v 1.12 2012/11/18 01:58:15 tom Exp $ * * Author: Thomas E Dickey */ @@ -50,6 +50,16 @@ #define BASE_Y 7 #define MAX_COLS 1024 +static void +failed(const char *s) +{ + int save = errno; + endwin(); + errno = save; + perror(s); + ExitProgram(EXIT_FAILURE); +} + static bool Quit(int ch) { @@ -87,6 +97,8 @@ test_inchs(int level, char **argv, WINDOW *chrwin, WINDOW *strwin) txtwin = stdscr; base_y = BASE_Y; } + if (txtwin == 0) + failed("cannot create txtwin"); keypad(txtwin, TRUE); /* enable keyboard mapping */ (void) cbreak(); /* take input chars one at a time, no wait for \n */ diff --git a/test/insdelln.c b/test/insdelln.c index ffca6aff..758f0887 100644 --- a/test/insdelln.c +++ b/test/insdelln.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: insdelln.c,v 1.6 2012/06/09 20:29:33 tom Exp $ + * $Id: insdelln.c,v 1.7 2012/11/18 00:37:58 tom Exp $ * * test-driver for deleteln, wdeleteln, insdelln, winsdelln, insertln, winsertln */ @@ -175,6 +175,8 @@ do_subwindow(WINDOW *win, STATUS * sp, void func(WINDOW *)) delwin(win1); touchwin(win); } else { + if (win1) + delwin(win1); beep(); } } diff --git a/test/knight.c b/test/knight.c index d9f81fac..2835cd8b 100644 --- a/test/knight.c +++ b/test/knight.c @@ -33,7 +33,7 @@ * Eric S. Raymond July 22 1995. Mouse support * added September 20th 1995. * - * $Id: knight.c,v 1.31 2010/11/13 20:44:21 tom Exp $ + * $Id: knight.c,v 1.32 2012/11/17 23:46:31 tom Exp $ */ #include @@ -614,8 +614,8 @@ play(void) ny = history[movecount].y; nx = history[movecount].x; if (nx < 0 || ny < 0) { - ny = lastrow; - nx = lastcol; + ny = (lastrow >= 0) ? lastrow : 0; + nx = (lastcol >= 0) ? lastcol : 0; } movecount = 0; board[ny][nx] = FALSE; diff --git a/test/ncurses.c b/test/ncurses.c index 6ff52e08..326c747c 100644 --- a/test/ncurses.c +++ b/test/ncurses.c @@ -40,7 +40,7 @@ AUTHOR Author: Eric S. Raymond 1993 Thomas E. Dickey (beginning revision 1.27 in 1996). -$Id: ncurses.c,v 1.378 2012/10/27 19:37:56 tom Exp $ +$Id: ncurses.c,v 1.379 2012/11/18 00:56:44 tom Exp $ ***************************************************************************/ @@ -1095,7 +1095,7 @@ wget_wch_test(unsigned level, WINDOW *win, int delay) } else if (c == 'g') { waddstr(win, "getstr test: "); echo(); - code = wgetn_wstr(win, wint_buf, sizeof(wint_buf) - 1); + code = wgetn_wstr(win, wint_buf, BUFSIZ - 1); noecho(); if (code == ERR) { wprintw(win, "wgetn_wstr returns an error."); @@ -1660,6 +1660,7 @@ get_wide_background(void) short pair; wchar_t wch[10]; + memset(&ch, 0, sizeof(ch)); if (getbkgrnd(&ch) != ERR) { if (getcchar(&ch, wch, &attr, &pair, 0) != ERR) { result = attr; @@ -2182,7 +2183,7 @@ wide_color_test(void) bool opt_wide = FALSE; bool opt_nums = FALSE; bool opt_xchr = FALSE; - wchar_t buffer[10]; + wchar_t buffer[80]; WINDOW *helpwin; if (COLORS * COLORS == COLOR_PAIRS) { @@ -5758,10 +5759,9 @@ display_form(FORM * f) set_form_sub(f, derwin(w, rows, cols, 1, 2)); box(w, 0, 0); keypad(w, TRUE); + if (post_form(f) != E_OK) + wrefresh(w); } - - if (post_form(f) != E_OK) - wrefresh(w); } static void diff --git a/test/newdemo.c b/test/newdemo.c index b7c5db61..566fc47c 100644 --- a/test/newdemo.c +++ b/test/newdemo.c @@ -2,7 +2,7 @@ * newdemo.c - A demo program using PDCurses. The program illustrate * the use of colours for text output. * - * $Id: newdemo.c,v 1.36 2012/06/09 19:17:29 tom Exp $ + * $Id: newdemo.c,v 1.37 2012/11/17 23:27:50 tom Exp $ */ #include @@ -113,12 +113,19 @@ SubWinTest(WINDOW *win) getbegyx(win, by, bx); sw = w / 3; sh = h / 3; - if ((swin1 = subwin(win, sh, sw, by + 3, bx + 5)) == NULL) + + if ((swin1 = subwin(win, sh, sw, by + 3, bx + 5)) == NULL) { return 1; - if ((swin2 = subwin(win, sh, sw, by + 4, bx + 8)) == NULL) + } + if ((swin2 = subwin(win, sh, sw, by + 4, bx + 8)) == NULL) { + delwin(swin1); return 1; - if ((swin3 = subwin(win, sh, sw, by + 5, bx + 11)) == NULL) + } + if ((swin3 = subwin(win, sh, sw, by + 5, bx + 11)) == NULL) { + delwin(swin1); + delwin(swin2); return 1; + } set_colors(swin1, 8, COLOR_RED, COLOR_BLUE); werase(swin1);