]> ncurses.scripts.mit.edu Git - ncurses.git/commitdiff
ncurses 5.9 - patch 20121117
authorThomas E. Dickey <dickey@invisible-island.net>
Sun, 18 Nov 2012 02:58:41 +0000 (02:58 +0000)
committerThomas E. Dickey <dickey@invisible-island.net>
Sun, 18 Nov 2012 02:58:41 +0000 (02:58 +0000)
> 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.

25 files changed:
NEWS
dist.mk
ncurses/base/keyok.c
ncurses/base/lib_freeall.c
ncurses/tinfo/lib_cur_term.c
ncurses/tinfo/lib_setup.c
ncurses/tinfo/make_hash.c
ncurses/tinfo/name_match.c
ncurses/tinfo/read_entry.c
package/debian/changelog
package/ncurses.spec
progs/infocmp.c
progs/tabs.c
progs/toe.c
test/bs.c
test/chgat.c
test/clip_printw.c
test/color_name.h
test/demo_forms.c
test/demo_menus.c
test/inchs.c
test/insdelln.c
test/knight.c
test/ncurses.c
test/newdemo.c

diff --git a/NEWS b/NEWS
index b3d48e933e239cc6a3e26d71c56134b5e39fda02..5245e26be4ed57768c926b08b8f580adf9649aea 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,7 +25,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
 -- 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
 -------------------------------------------------------------------------------
 
 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.
 
 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
 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 92767c2987e84ea24c948510a0fb20f4a7648e43..66aecea0a0d29826b17fb7385152683fdef69507 100644 (file)
--- a/dist.mk
+++ b/dist.mk
@@ -25,7 +25,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
 # 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
 # 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
 # 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)
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
index 6127fd2796de75ea49b44aa843002f85ad1e913c..00e936dacde991fd8233451558db5a2b94342b6c 100644 (file)
@@ -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            *
  *                                                                          *
  * 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 <curses.priv.h>
 
 
 #include <curses.priv.h>
 
-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
 
 /*
  * 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,
 
            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,
                }
            } 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);
+                   }
                }
            }
        }
                }
            }
        }
index 38d73aa25204b96a1a3f0598814a2a4cb13dc729..031374924f002cb75159eaef9f4701a995735a6b 100644 (file)
@@ -39,7 +39,7 @@
 extern int malloc_errfd;       /* FIXME */
 #endif
 
 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
 
 /*
  * 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)) {
 
            /* 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)) {
                bool found = FALSE;
 
                for (each_window(SP_PARM, q)) {
+                   WINDOW *q_win = &(q->win);
                    if ((p != q)
                    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) {
                        found = TRUE;
                        break;
                    }
                }
 
                if (!found) {
-                   if (delwin(&(p->win)) != ERR)
+                   if (delwin(p_win) != ERR)
                        deleted = TRUE;
                    break;
                }
                        deleted = TRUE;
                    break;
                }
index 86e130e78527b77aa6b8e81301fb0efbbd8186b8..c67e163103eeac0b2a4d90441e65f535974f2f25 100644 (file)
@@ -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            *
  *                                                                          *
  * 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 <curses.priv.h>
 #include <termcap.h>           /* ospeed */
 
 #include <curses.priv.h>
 #include <termcap.h>           /* 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.
 
 #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
 
        FreeIfNeeded(termp->_termname);
 #if USE_HOME_TERMINFO
-       if (_nc_globals.home_terminfo != 0)
+       if (_nc_globals.home_terminfo != 0) {
            FreeAndNull(_nc_globals.home_terminfo);
            FreeAndNull(_nc_globals.home_terminfo);
+       }
 #endif
 #ifdef USE_TERM_DRIVER
        if (TCB->drv)
 #endif
 #ifdef USE_TERM_DRIVER
        if (TCB->drv)
index 60ce2c68f9024f58f596db130d447cbea6c9472e..83742d5b78baf38c3ea3e58b01e71bc45150df4f 100644 (file)
@@ -48,7 +48,7 @@
 #include <locale.h>
 #endif
 
 #include <locale.h>
 #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)) {
        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 {
            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) {
            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
        ret_error1(TGETENT_YES, "I can't handle hardcopy terminals.\n", tname);
     }
 #endif
index 8fb2538c48f49c0be830022b132021093363d3c6..99e4bd4fbd781eb813760ef975d3616bc7e73bea 100644 (file)
@@ -44,7 +44,7 @@
 
 #include <ctype.h>
 
 
 #include <ctype.h>
 
-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()
 
 /*
  *     _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 */
 
 
 #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)
 {
 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;
        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")) {
        name_table[n].nte_link = -1;    /* end-of-hash */
        name_table[n].nte_name = strdup(list[column]);
        if (!strcmp(list[2], "bool")) {
index fccd26491e44d611d603d26e7d3bc546d5f2795e..a4433bc97e96d9b7b728f12f6d340a953a06ed9b 100644 (file)
@@ -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            *
  *                                                                          *
  * 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 <curses.priv.h>
 #include <tic.h>
 
 #include <curses.priv.h>
 #include <tic.h>
 
-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
 
 
 #define FirstName _nc_globals.first_name
 
@@ -62,8 +62,9 @@ _nc_first_name(const char *const sp)
 
 #if NO_LEAKS
     if (sp == 0) {
 
 #if NO_LEAKS
     if (sp == 0) {
-       if (FirstName != 0)
+       if (FirstName != 0) {
            FreeAndNull(FirstName);
            FreeAndNull(FirstName);
+       }
     } else
 #endif
     {
     } else
 #endif
     {
index a14bad68d9268fa5beb9020a47cb69456ac286ba..47852ad1dcc3015451e306dea15200f0b5cfcc21 100644 (file)
@@ -41,7 +41,7 @@
 
 #include <tic.h>
 
 
 #include <tic.h>
 
-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))
 
 
 #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));
        }
 
        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);
        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 (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);
                return (TGETENT_NO);
            if ((ptr->ext_Names = TYPE_CALLOC(char *, need)) == 0)
                  return (TGETENT_NO);
index bcc4a375ba0f3e114a149f26ea0e2b250386f9c2..2fb230dc73fbe70f7aefde8e3ed041bc2b240dbd 100644 (file)
@@ -1,8 +1,8 @@
-ncurses6 (5.9-20121110) unstable; urgency=low
+ncurses6 (5.9-20121117) unstable; urgency=low
 
   * latest weekly patch
 
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 10 Nov 2012 16:02:42 -0500
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 17 Nov 2012 11:58:08 -0500
 
 ncurses6 (5.9-20120608) unstable; urgency=low
 
 
 ncurses6 (5.9-20120608) unstable; urgency=low
 
index 35f69bc538917f7dafa9573beedf84c0c970625d..d7b6901b7c57cf8d449ac0db07d2fde4cdd19dc7 100644 (file)
@@ -1,7 +1,7 @@
 Summary: shared libraries for terminal handling
 Name: ncurses6
 Release: 5.9
 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
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{release}-%{version}.tgz
index 6311a0896e12fa3471e56b1967264fe1d0eac85e..506a374e40177d96c18e6582f495050282845de8 100644 (file)
@@ -42,7 +42,7 @@
 
 #include <dump_entry.h>
 
 
 #include <dump_entry.h>
 
-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 "}"
 
 #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));
        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");
     }
        if (initializer == 0)
            failed("any_initializer");
     }
index 07790f831d9df89d2361103d5aed75e473fa6d48..bded0b04b259812db51be662d6305ac4a7dbc00c 100644 (file)
@@ -37,7 +37,7 @@
 #define USE_LIBTINFO
 #include <progs.priv.h>
 
 #define USE_LIBTINFO
 #include <progs.priv.h>
 
-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;
 
 
 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;
 }
 
     return result;
 }
index 56c9d9fb7e277cf846d9201406b33d66c21cf239..f60d84e853c027981272ea2ea15a58ae05049a13 100644 (file)
@@ -44,7 +44,7 @@
 #include <hashed_db.h>
 #endif
 
 #include <hashed_db.h>
 #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, ".."))
 
 
 #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);
                        (void) fprintf(stderr,
                                       "%s: couldn't open terminfo file %s.\n",
                                       _nc_progname, name_2);
+                       free(cwd_buf);
                        free(name_2);
                        free(name_2);
+                       closedir(entrydir);
+                       closedir(termdir);
                        return (EXIT_FAILURE);
                    }
 
                        return (EXIT_FAILURE);
                    }
 
index 12df0934a58d6abef9885ae7dab0b4bfb2518866..53a4df7637c9d6f247c99e7a501a904eddd87881 100644 (file)
--- 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
  *
  * 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 <test.priv.h>
  */
 
 #include <test.priv.h>
@@ -863,7 +863,9 @@ plyturn(void)
            m = " You'll pick up survivors from my %s, I hope...!";
            break;
        }
            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);
        (void) beep();
     }
     return (hit);
index 53ecfd7cedf4c9fdeaf7c19418278cb2691cdf60..919b5c9e3b98a2fcf6b0b9eff7b6bcdf1d95d6ab 100644 (file)
@@ -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            *
  *                                                                          *
  * 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.                                                           *
  ****************************************************************************/
 /*
  * 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
  */
  *
  * 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 {
        delwin(win1);
        touchwin(win);
     } else {
+       if (win1 != 0)
+           delwin(win1);
        beep();
     }
 }
        beep();
     }
 }
index 4009ab13eafd9f08680361bd2b3b5f6ab413e247..6d6d590241ae2e5f301845eec5fe50cef6871103 100644 (file)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
  * 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.
  */
  *
  * 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 {
        delwin(win1);
        touchwin(win);
     } else {
+       if (win1)
+           delwin(win1);
        beep();
     }
 }
        beep();
     }
 }
@@ -337,12 +339,13 @@ test_clipping(WINDOW *win)
                need = (unsigned) getmaxx(win) - 1;
                strcpy(fmt, "%c%s%c");
            }
                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, ']');
                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':
            }
            break;
        case 'w':
index 0964dce15990d7beeb093f1ea4ceea4679b5b989..81a3b3125759bfd426c7e0396b1bfed3a272b3c1 100644 (file)
@@ -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            *
  *                                                                          *
  * 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.                                                           *
  ****************************************************************************/
 /*
  * 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
  */
 
 #ifndef __COLORNAME_H
@@ -88,7 +88,7 @@ color_name(int color)
     static char temp[20];
     const char *result = 0;
 
     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) {
        sprintf(temp, "%d", color);
        result = temp;
     } else if (color < 0) {
index 455b7bb7f3dfe7afcaa731d853945045a9912a61..d20469460632ddeb2125ef6f73b6ca602f76fdc0 100644 (file)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
  * 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
  *
  * 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);
        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
 }
 
 static void
index 8f19281dfa6945d06119cfbfabac1d8b983b5aa8..dd1bd4fcbc31c11e60535a6ec465e7121e9a9c6f 100644 (file)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
  * 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
  *
  * 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);
                free((char *) blob);
            }
            free(items);
+           items = 0;
        }
 #ifdef TRACE
        if ((count > 0) && (m == mpTrace)) {
            ITEM **ip = items;
        }
 #ifdef TRACE
        if ((count > 0) && (m == mpTrace)) {
            ITEM **ip = items;
-           while (*ip)
-               free(*ip++);
+           if (ip != 0) {
+               while (*ip)
+                   free(*ip++);
+           }
        }
 #endif
     }
        }
 #endif
     }
@@ -386,6 +389,8 @@ build_select_menu(MenuNo number, char *filename)
                }
                loaded_file = TRUE;
            }
                }
                loaded_file = TRUE;
            }
+           if (ap == 0)
+               free(items);
        }
     }
     if (ap == 0) {
        }
     }
     if (ap == 0) {
index f07a2bdabd0db8728605b04a0a98d73451032404..be3aab86f57829499c1b4d4156414023868dd040 100644 (file)
@@ -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            *
  *                                                                          *
  * 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.                                                           *
  ****************************************************************************/
 /*
  * 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
  */
  *
  * Author: Thomas E Dickey
  */
 #define BASE_Y 7
 #define MAX_COLS 1024
 
 #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)
 {
 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;
     }
        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 */
 
     keypad(txtwin, TRUE);      /* enable keyboard mapping */
     (void) cbreak();           /* take input chars one at a time, no wait for \n */
index ffca6aff68f28973039a4711a276c5bc6247c4be..758f0887f2ba5be83a651d25344317eab20247be 100644 (file)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
  * 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
  */
  *
  * 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 {
        delwin(win1);
        touchwin(win);
     } else {
+       if (win1)
+           delwin(win1);
        beep();
     }
 }
        beep();
     }
 }
index d9f81facacec814e13cdb984975523867b7cbc13..2835cd8b8d4689707dc07de372b6ef1c38b304ba 100644 (file)
@@ -33,7 +33,7 @@
  * Eric S. Raymond <esr@snark.thyrsus.com> July 22 1995.  Mouse support
  * added September 20th 1995.
  *
  * Eric S. Raymond <esr@snark.thyrsus.com> 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 <test.priv.h>
  */
 
 #include <test.priv.h>
@@ -614,8 +614,8 @@ play(void)
                    ny = history[movecount].y;
                    nx = history[movecount].x;
                    if (nx < 0 || ny < 0) {
                    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;
                    }
                    movecount = 0;
                    board[ny][nx] = FALSE;
index 6ff52e08fd2902660b1e1962e930df8e07c84c35..326c747cad027cb542b0d50ae06e8ce1e3ad0cc1 100644 (file)
@@ -40,7 +40,7 @@ AUTHOR
    Author: Eric S. Raymond <esr@snark.thyrsus.com> 1993
            Thomas E. Dickey (beginning revision 1.27 in 1996).
 
    Author: Eric S. Raymond <esr@snark.thyrsus.com> 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();
        } 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.");
            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];
 
     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;
     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;
     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) {
     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);
        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
 }
 
 static void
index b7c5db61acfc8add1db9149d31c97d6980b4a213..566fc47c6a6c756a1feec8c2a6b9cf1119bdc0f3 100644 (file)
@@ -2,7 +2,7 @@
  *  newdemo.c  -       A demo program using PDCurses. The program illustrate
  *                     the use of colours for text output.
  *
  *  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 <test.priv.h>
  */
 
 #include <test.priv.h>
@@ -113,12 +113,19 @@ SubWinTest(WINDOW *win)
     getbegyx(win, by, bx);
     sw = w / 3;
     sh = h / 3;
     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;
        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;
        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;
        return 1;
+    }
 
     set_colors(swin1, 8, COLOR_RED, COLOR_BLUE);
     werase(swin1);
 
     set_colors(swin1, 8, COLOR_RED, COLOR_BLUE);
     werase(swin1);