]> ncurses.scripts.mit.edu Git - ncurses.git/commitdiff
ncurses 6.4 - patch 20230624
authorThomas E. Dickey <dickey@invisible-island.net>
Sun, 25 Jun 2023 00:38:02 +0000 (00:38 +0000)
committerThomas E. Dickey <dickey@invisible-island.net>
Sun, 25 Jun 2023 00:38:02 +0000 (00:38 +0000)
+ fixes for out-of-memory condition (report by "eaglegai").

31 files changed:
NEWS
VERSION
dist.mk
ncurses/base/key_defined.c
ncurses/base/tries.c
ncurses/curses.priv.h
ncurses/tinfo/access.c
ncurses/tinfo/add_tries.c
ncurses/tinfo/comp_hash.c
ncurses/tinfo/db_iterator.c
ncurses/tinfo/lib_setup.c
ncurses/tinfo/lib_tparm.c
ncurses/tinfo/obsolete.c
ncurses/tinfo/read_entry.c
ncurses/tinfo/read_termcap.c
ncurses/trace/lib_tracedmp.c
ncurses/trace/trace_buf.c
ncurses/trace/varargs.c
ncurses/tty/hardscroll.c
ncurses/tty/lib_mvcur.c
package/debian-mingw/changelog
package/debian-mingw64/changelog
package/debian/changelog
package/mingw-ncurses.nsi
package/mingw-ncurses.spec
package/ncurses.spec
package/ncursest.spec
test/demo_defkey.c
test/list_keys.c
test/sp_tinfo.c
test/test_setupterm.c

diff --git a/NEWS b/NEWS
index b8147e206aae2d2de529c05dc95eebf59baa546e..dd032a577f289b93c157a862c2a7d19b6f000b19 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -26,7 +26,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: NEWS,v 1.3967 2023/06/17 17:17:42 tom Exp $
+-- $Id: NEWS,v 1.3969 2023/06/24 22:59:35 tom Exp $
 -------------------------------------------------------------------------------
 
 This is a log of changes that ncurses has gone through since Zeyd started
@@ -46,6 +46,9 @@ 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.
 
+20230624
+       + fixes for out-of-memory condition (report by "eaglegai").
+
 20230617
        + markup manpages with revision information (prompted by discussion
          with Bjarni Ingi Gislason).
diff --git a/VERSION b/VERSION
index efbf785fb9a4fe78be125bc86b67e5ec3f9d6d25..87165874757445a9e83543580bf37a90ef1b3e3c 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-5:0:10 6.4     20230617
+5:0:10 6.4     20230624
diff --git a/dist.mk b/dist.mk
index fb55f3aefa8853b5afa228516a4c2b6b85e4d082..999e346845f2935d631332ef6f027a809fa44d0e 100644 (file)
--- a/dist.mk
+++ b/dist.mk
@@ -26,7 +26,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: dist.mk,v 1.1550 2023/06/17 09:47:23 tom Exp $
+# $Id: dist.mk,v 1.1551 2023/06/24 10:06:22 tom Exp $
 # Makefile for creating ncurses distributions.
 #
 # This only needs to be used directly as a makefile by developers, but
@@ -38,7 +38,7 @@ SHELL = /bin/sh
 # These define the major/minor/patch versions of ncurses.
 NCURSES_MAJOR = 6
 NCURSES_MINOR = 4
-NCURSES_PATCH = 20230617
+NCURSES_PATCH = 20230624
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
index 25d5a674e1b8524fef3d2233c9f80cd662288463..147e5fe2db93c9bac85c0acdaa637c5eb2830e50 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 2003-2006,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -32,8 +32,9 @@
  ****************************************************************************/
 
 #include <curses.priv.h>
+#include <tic.h>
 
-MODULE_ID("$Id: key_defined.c,v 1.10 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: key_defined.c,v 1.11 2023/06/24 15:36:32 tom Exp $")
 
 static int
 find_definition(TRIES * tree, const char *str)
@@ -41,7 +42,7 @@ find_definition(TRIES * tree, const char *str)
     TRIES *ptr;
     int result = OK;
 
-    if (str != 0 && *str != '\0') {
+    if (VALID_STRING(str) && *str != '\0') {
        for (ptr = tree; ptr != 0; ptr = ptr->sibling) {
            if (UChar(*str) == UChar(ptr->ch)) {
                if (str[1] == '\0' && ptr->child != 0) {
index 0f309c213c456f87ceb6fdf9889c33a29aab5716..0f8c0516e88f0ab36cebfcec4ef368345d2aa528 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -39,8 +39,9 @@
 */
 
 #include <curses.priv.h>
+#include <tic.h>
 
-MODULE_ID("$Id: tries.c,v 1.31 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: tries.c,v 1.32 2023/06/24 15:36:23 tom Exp $")
 
 /*
  * Expand a keycode into the string that it corresponds to, returning null if
@@ -124,7 +125,7 @@ _nc_remove_string(TRIES ** tree, const char *string)
 {
     T((T_CALLED("_nc_remove_string(%p,%s)"), (void *) tree, _nc_visbuf(string)));
 
-    if (string == 0 || *string == 0)
+    if (!VALID_STRING(string) || *string == 0)
        returnCode(FALSE);
 
     while (*tree != 0) {
index e7146ef7fc762267d8fbd063d29a4f4b8187e9e4..3fd8e0d269e59eef5823f45e8922a93f08459021 100644 (file)
@@ -35,7 +35,7 @@
  ****************************************************************************/
 
 /*
- * $Id: curses.priv.h,v 1.669 2023/06/06 22:31:04 tom Exp $
+ * $Id: curses.priv.h,v 1.670 2023/06/24 13:00:26 tom Exp $
  *
  *     curses.priv.h
  *
@@ -574,10 +574,10 @@ extern NCURSES_EXPORT(void)     _nc_set_no_padding(SCREEN *);
 #define SET_SCREEN_PAIR(s,p)   SetPair(SCREEN_ATTRS(s), p)
 
 #if USE_REENTRANT || NCURSES_SP_FUNCS
-NCURSES_EXPORT(int *)        _nc_ptr_Lines (SCREEN *);
-NCURSES_EXPORT(int *)        _nc_ptr_Cols (SCREEN *);
-NCURSES_EXPORT(int *)        _nc_ptr_Tabsize (SCREEN *);
-NCURSES_EXPORT(int *)        _nc_ptr_Escdelay (SCREEN *);
+extern NCURSES_EXPORT(int *)    _nc_ptr_Lines (SCREEN *);
+extern NCURSES_EXPORT(int *)    _nc_ptr_Cols (SCREEN *);
+extern NCURSES_EXPORT(int *)    _nc_ptr_Tabsize (SCREEN *);
+extern NCURSES_EXPORT(int *)    _nc_ptr_Escdelay (SCREEN *);
 #endif
 
 #if USE_REENTRANT
@@ -1540,6 +1540,9 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 
 #define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
 
+#include <nc_alloc.h>
+#include <nc_access.h>
+
 #define FreeIfNeeded(p)  if ((p) != 0) free(p)
 
 /* FreeAndNull() is not a comma-separated expression because some compilers
@@ -1547,8 +1550,18 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
  */
 #define FreeAndNull(p)   do { free(p); p = 0; } while (0)
 
-#include <nc_alloc.h>
-#include <nc_access.h>
+#ifdef EXP_OOM_TESTING
+extern NCURSES_EXPORT(void *)  _nc_oom_malloc(size_t size);
+extern NCURSES_EXPORT(void *)  _nc_oom_calloc(size_t nmemb, size_t size);
+extern NCURSES_EXPORT(void *)  _nc_oom_realloc(void *ptr, size_t size);
+extern NCURSES_EXPORT(void)    _nc_oom_free(void *ptr);
+extern NCURSES_EXPORT(char *)  _nc_oom_strdup(const char *ptr);
+#define malloc(size)           _nc_oom_malloc(size)
+#define calloc(nmemb, size)    _nc_oom_calloc(nmemb, size)
+#define realloc(ptr, size)     _nc_oom_realloc(ptr, size)
+#define free(ptr)              _nc_oom_free(ptr)
+#define strdup(ptr)            _nc_oom_strdup(ptr)
+#endif
 
 /*
  * Use these for tic/infocmp malloc failures.  Generally the ncurses library
@@ -1968,7 +1981,7 @@ extern NCURSES_EXPORT(int)  _nc_msec_cost (const char *const, int);
 
 /* lib_addch.c */
 #if USE_WIDEC_SUPPORT
-NCURSES_EXPORT(int) _nc_build_wch(WINDOW *win, ARG_CH_T ch);
+extern NCURSES_EXPORT(int) _nc_build_wch(WINDOW *win, ARG_CH_T ch);
 #endif
 
 /* lib_addstr.c */
@@ -2147,7 +2160,7 @@ extern NCURSES_EXPORT(const TERMTYPE2 *) _nc_fallback2 (const char *);
 #define _nc_fallback2(tp) _nc_fallback(tp)
 #endif
 
-NCURSES_EXPORT(void) _nc_copy_termtype(TERMTYPE *, const TERMTYPE *);
+extern NCURSES_EXPORT(void) _nc_copy_termtype(TERMTYPE *, const TERMTYPE *);
 
 #if NCURSES_EXT_NUMBERS
 extern NCURSES_EXPORT(void) _nc_copy_termtype2 (TERMTYPE2 *, const TERMTYPE2 *);
@@ -2229,7 +2242,7 @@ extern int __MINGW_NOTHROW _nc_mblen(const char *, size_t);
 
 #if defined(_NC_WINDOWS) || defined(_NC_MINGW)
 /* see wcwidth.c */
-NCURSES_EXPORT(int) mk_wcwidth(wchar_t);
+extern NCURSES_EXPORT(int) mk_wcwidth(wchar_t);
 #define wcwidth(ucs) _nc_wcwidth(ucs)
 #endif
 
@@ -2621,8 +2634,8 @@ extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *, chtype);
 #endif
 
 #ifdef EXP_XTERM_1005
-NCURSES_EXPORT(int) _nc_conv_to_utf8(unsigned char *, unsigned, unsigned);
-NCURSES_EXPORT(int) _nc_conv_to_utf32(unsigned *, const char *, unsigned);
+extern NCURSES_EXPORT(int) _nc_conv_to_utf8(unsigned char *, unsigned, unsigned);
+extern NCURSES_EXPORT(int) _nc_conv_to_utf32(unsigned *, const char *, unsigned);
 #endif
 
 #ifdef __cplusplus
index 6c415acaa5cf86ec468aed4ac75ece5c34b844f4..50a5769c3d6358fef4af8f67e9ee7cc8aeddc2b0 100644 (file)
@@ -52,7 +52,7 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: access.c,v 1.36 2023/04/22 21:19:56 tom Exp $")
+MODULE_ID("$Id: access.c,v 1.37 2023/06/24 21:55:09 tom Exp $")
 
 #define LOWERCASE(c) ((isalpha(UChar(c)) && isupper(UChar(c))) ? tolower(UChar(c)) : (c))
 
@@ -70,8 +70,8 @@ _nc_rootname(char *path)
     static char *temp;
     char *s;
 
-    temp = strdup(result);
-    result = temp;
+    if ((temp = strdup(result)) != 0)
+       result = temp;
 #if !MIXEDCASE_FILENAMES
     for (s = result; *s != '\0'; ++s) {
        *s = (char) LOWERCASE(*s);
index d41f488300ae3f799d2eab7e69f397e6073ca5df..9d215575fec02f710780bb7fac7d6eff886f8e06 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2020,2023 Thomas E. Dickey                                *
  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -39,8 +39,9 @@
 */
 
 #include <curses.priv.h>
+#include <tic.h>
 
-MODULE_ID("$Id: add_tries.c,v 1.12 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: add_tries.c,v 1.13 2023/06/24 15:36:13 tom Exp $")
 
 #define SET_TRY(dst,src) if ((dst->ch = *src++) == 128) dst->ch = '\0'
 #define CMP_TRY(a,b) ((a)? (a == b) : (b == 128))
@@ -53,7 +54,7 @@ _nc_add_to_try(TRIES ** tree, const char *str, unsigned code)
 
     T((T_CALLED("_nc_add_to_try(%p, %s, %u)"),
        (void *) *tree, _nc_visbuf(str), code));
-    if (txt == 0 || *txt == '\0' || code == 0)
+    if (!VALID_STRING(str) || *txt == '\0' || code == 0)
        returnCode(ERR);
 
     if ((*tree) != 0) {
index eff60f127c01e475b575fcdc93ae013d319cf05c..4b081afa2c2842d1ef18587c53ddd4d766472908 100644 (file)
@@ -45,7 +45,7 @@
 #include <tic.h>
 #include <hashsize.h>
 
-MODULE_ID("$Id: comp_hash.c,v 1.54 2023/04/22 15:12:57 tom Exp $")
+MODULE_ID("$Id: comp_hash.c,v 1.55 2023/06/24 13:29:43 tom Exp $")
 
 /*
  * Finds the entry for the given string in the hash table if present.
@@ -103,14 +103,16 @@ _nc_find_type_entry(const char *string,
        && data->table_data[hashvalue] >= 0) {
        const struct name_table_entry *const table = _nc_get_table(termcap);
 
-       ptr = table + data->table_data[hashvalue];
-       while (ptr->nte_type != type
-              || !data->compare_names(ptr->nte_name, string)) {
-           if (ptr->nte_link < 0) {
-               ptr = 0;
-               break;
+       if (table != NULL) {
+           ptr = table + data->table_data[hashvalue];
+           while (ptr->nte_type != type
+                  || !data->compare_names(ptr->nte_name, string)) {
+               if (ptr->nte_link < 0) {
+                   ptr = 0;
+                   break;
+               }
+               ptr = table + (ptr->nte_link + data->table_data[data->table_size]);
            }
-           ptr = table + (ptr->nte_link + data->table_data[data->table_size]);
        }
     }
 
index e69e0f34e71ccc66ff6ef26a50b790fcb02f3554..db3872e3f90d3e932ddd54bc35f5802026269f1a 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2020,2022 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 2006-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -44,7 +44,7 @@
 #include <hashed_db.h>
 #endif
 
-MODULE_ID("$Id: db_iterator.c,v 1.49 2022/04/23 20:03:15 tom Exp $")
+MODULE_ID("$Id: db_iterator.c,v 1.50 2023/06/24 21:52:32 tom Exp $")
 
 #define HaveTicDirectory _nc_globals.have_tic_directory
 #define KeepTicDirectory _nc_globals.keep_tic_directory
@@ -383,8 +383,11 @@ _nc_first_db(DBDIRS * state, int *offset)
                 */
                for (j = 0; my_list[j] != 0; ++j) {
 #ifdef TERMINFO
-                   if (*my_list[j] == '\0')
-                       my_list[j] = strdup(TERMINFO);
+                   if (*my_list[j] == '\0') {
+                       char *my_copy = strdup(TERMINFO);
+                       if (my_copy != 0)
+                           my_list[j] = my_copy;
+                   }
 #endif
                    trim_formatting(my_list[j]);
                    for (k = 0; k < j; ++k) {
index db93a368fda162022a48dda6edda2468e41140f7..cdc6726c6064037fc79fcade14ad323cd054d331 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2021,2022 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -49,7 +49,7 @@
 #include <locale.h>
 #endif
 
-MODULE_ID("$Id: lib_setup.c,v 1.218 2022/08/13 18:12:22 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.219 2023/06/24 13:25:14 tom Exp $")
 
 /****************************************************************************
  *
@@ -679,10 +679,9 @@ TINFO_SETUP_TERM(TERMINAL **tp,
 #endif
     }
     myname = strdup(tname);
-
-    if (strlen(myname) > MAX_NAME_SIZE) {
+    if (myname == NULL || strlen(myname) > MAX_NAME_SIZE) {
        ret_error(TGETENT_ERR,
-                 "TERM environment must be <= %d characters.\n",
+                 "TERM environment must be 1..%d characters.\n",
                  MAX_NAME_SIZE,
                  free(myname));
     }
index 93af835049b1e25591c6d87d2582d4508b95ac4f..0d6d7b3c2f241c608157cc80de89b0f2128b48b6 100644 (file)
@@ -53,7 +53,7 @@
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: lib_tparm.c,v 1.146 2023/04/23 20:57:33 tom Exp $")
+MODULE_ID("$Id: lib_tparm.c,v 1.150 2023/06/24 16:12:52 tom Exp $")
 
 /*
  *     char *
@@ -177,19 +177,21 @@ _nc_free_tparm(TERMINAL *termp)
 #if HAVE_TSEARCH
     if (MyCount != 0) {
        delete_tparm = typeCalloc(TPARM_DATA *, MyCount);
-       which_tparm = 0;
-       twalk(MyCache, visit_nodes);
-       for (which_tparm = 0; which_tparm < MyCount; ++which_tparm) {
-           TPARM_DATA *ptr = delete_tparm[which_tparm];
-           if (ptr != NULL) {
-               tdelete(ptr, &MyCache, cmp_format);
-               free((char *) ptr->format);
-               free(ptr);
+       if (delete_tparm != NULL) {
+           which_tparm = 0;
+           twalk(MyCache, visit_nodes);
+           for (which_tparm = 0; which_tparm < MyCount; ++which_tparm) {
+               TPARM_DATA *ptr = delete_tparm[which_tparm];
+               if (ptr != NULL) {
+                   tdelete(ptr, &MyCache, cmp_format);
+                   free((char *) ptr->format);
+                   free(ptr);
+               }
            }
+           which_tparm = 0;
+           twalk(MyCache, visit_nodes);
+           FreeAndNull(delete_tparm);
        }
-       which_tparm = 0;
-       twalk(MyCache, visit_nodes);
-       FreeAndNull(delete_tparm);
        MyCount = 0;
        which_tparm = 0;
     }
@@ -796,6 +798,11 @@ tparam_internal(TPARM_STATE *tps, const char *string, TPARM_DATA *data)
 
     tparm_trace_call(tps, string, data);
 
+    if (TPS(fmt_buff) == NULL) {
+       T((T_RETURN("<null>")));
+       return NULL;
+    }
+
     while ((cp - string) < (int) len2) {
        if (*cp != '%') {
            save_char(tps, UChar(*cp));
index 972a9a180e78068827b5a7a607a3fb36659db7b7..e63f8a868742d4449ff83724806ade743b5c8586 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 2013-2014,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -37,7 +37,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: obsolete.c,v 1.6 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: obsolete.c,v 1.9 2023/06/24 22:02:25 tom Exp $")
 
 /*
  * Obsolete entrypoint retained for binary compatibility.
@@ -238,3 +238,94 @@ _nc_conv_to_utf32(unsigned *target, const char *source, unsigned limit)
 #undef CH
 }
 #endif /* EXP_XTERM_1005 */
+
+#ifdef EXP_OOM_TESTING
+/*
+ * Out-of-memory testing, suitable for checking if initialization (and limited
+ * running) recovers from errors due to insufficient memory.  In practice, this
+ * is unlikely except with artifically constructed tests (or poorly behaved
+ * applications).
+ */
+#undef malloc
+#undef calloc
+#undef realloc
+#undef free
+#undef strdup
+
+static long oom_limit = -1;
+static long oom_count = 0;
+
+static bool
+oom_check(void)
+{
+    static bool initialized = FALSE;
+    static bool triggered = FALSE;
+    bool result = FALSE;
+
+    if (!initialized) {
+       char *env = getenv("NCURSES_OOM_TESTING");
+       initialized = TRUE;
+       if (env != NULL) {
+           char *check;
+           oom_limit = strtol(env, &check, 0);
+           if (check != NULL && *check != '\0')
+               oom_limit = 0;
+       }
+    }
+    if (oom_limit >= 0) {
+       result = (++oom_count > oom_limit);
+       if (result && !triggered) {
+           triggered = TRUE;
+           T(("out-of-memory"));
+       }
+    }
+    return result;
+}
+
+NCURSES_EXPORT(void *)
+_nc_oom_malloc(size_t size)
+{
+    char *result = (oom_check()
+                   ? NULL
+                   : malloc(size));
+    T(("oom #%ld malloc(%ld) %p", oom_count, size, result));
+    return result;
+}
+
+NCURSES_EXPORT(void *)
+_nc_oom_calloc(size_t nmemb, size_t size)
+{
+    char *result = (oom_check()
+                   ? NULL
+                   : calloc(nmemb, size));
+    T(("oom #%ld calloc(%ld, %ld) %p", oom_count, nmemb, size, result));
+    return result;
+}
+
+NCURSES_EXPORT(void *)
+_nc_oom_realloc(void *ptr, size_t size)
+{
+    char *result = (oom_check()
+                   ? NULL
+                   : realloc(ptr, size));
+    T(("oom #%ld realloc(%p, %ld) %p", oom_count, ptr, size, result));
+    return result;
+}
+
+NCURSES_EXPORT(void)
+_nc_oom_free(void *ptr)
+{
+    T(("oom #%ld free(%p)", oom_count, ptr));
+    free(ptr);
+}
+
+NCURSES_EXPORT(char *)
+_nc_oom_strdup(const char *ptr)
+{
+    char *result = (oom_check()
+                   ? NULL
+                   : strdup(ptr));
+    T(("oom #%ld strdup(%p) %p", oom_count, ptr, result));
+    return result;
+}
+#endif /* EXP_OOM_TESTING */
index 762c6c68c18b5b7af2d6b23555bec23c4408929b..3591a5080f21c8b40a582125b6e9115ae959b29c 100644 (file)
@@ -42,7 +42,7 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: read_entry.c,v 1.169 2023/06/15 20:51:06 tom Exp $")
+MODULE_ID("$Id: read_entry.c,v 1.170 2023/06/24 18:09:05 tom Exp $")
 
 #define MyNumber(n) (short) LOW_MSB(n)
 
@@ -803,6 +803,9 @@ _nc_read_tic_entry(char *filename,
        int reccnt = 0;
        char *save = strdup(name);
 
+       if (save == 0)
+           returnDB(code);
+
        memset(&key, 0, sizeof(key));
        key.data = save;
        key.size = strlen(save);
index 9ff2b2bace3cbf48dc30d73e253712f9fac702f6..1a294848b82732519adb681698e23e4af5a76246 100644 (file)
@@ -57,7 +57,7 @@
 #include <sys/types.h>
 #include <tic.h>
 
-MODULE_ID("$Id: read_termcap.c,v 1.103 2023/04/28 20:59:14 tom Exp $")
+MODULE_ID("$Id: read_termcap.c,v 1.104 2023/06/24 21:53:16 tom Exp $")
 
 #if !PURE_TERMINFO
 
@@ -1055,15 +1055,15 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE2 *const tp)
     if (normal) {              /* normal case */
        char envhome[PATH_MAX], *h;
 
-       copied = strdup(get_termpath());
-       for (cp = copied; *cp; cp++) {
-           if (*cp == NCURSES_PATHSEP)
-               *cp = '\0';
-           else if (cp == copied || cp[-1] == '\0') {
-               ADD_TC(cp, filecount);
+       if ((copied = strdup(get_termpath())) != 0) {
+           for (cp = copied; *cp; cp++) {
+               if (*cp == NCURSES_PATHSEP)
+                   *cp = '\0';
+               else if (cp == copied || cp[-1] == '\0') {
+                   ADD_TC(cp, filecount);
+               }
            }
        }
-
 #define PRIVATE_CAP "%.*s/.termcap"
 
        if (use_terminfo_vars() && (h = getenv("HOME")) != NULL && *h != '\0'
index 3b7ea0749986d691158a9b7843c8c9bd2e1b381a..529148bb785a6259672485a1557fab965f987c60 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 1998-2012,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -40,7 +40,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_tracedmp.c,v 1.36 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_tracedmp.c,v 1.37 2023/06/24 15:49:45 tom Exp $")
 
 #ifdef TRACE
 
@@ -71,9 +71,9 @@ _tracedump(const char *name, WINDOW *win)
     if (++width + 1 > (int) my_length) {
        my_length = (unsigned) (2 * (width + 1));
        my_buffer = typeRealloc(char, my_length, my_buffer);
-       if (my_buffer == 0)
-           return;
     }
+    if (my_buffer == 0)
+       return;
 
     for (n = 0; n <= win->_maxy; ++n) {
        char *ep = my_buffer;
index 7e6384b54153662c54b25ccbe2c033d5ad2e8a7c..91b12e45c248aaab6e10b724965799cc5d5257f7 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 1998-2011,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -36,7 +36,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: trace_buf.c,v 1.21 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: trace_buf.c,v 1.22 2023/06/24 13:37:25 tom Exp $")
 
 #ifdef TRACE
 
@@ -104,7 +104,11 @@ _nc_trace_buf(int bufnum, size_t want)
 NCURSES_EXPORT(char *)
 _nc_trace_bufcat(int bufnum, const char *value)
 {
-    char *buffer = _nc_trace_alloc(bufnum, (size_t) 0);
+    char *buffer;
+
+    if (value == NULL)
+       value = "";
+    buffer = _nc_trace_alloc(bufnum, (size_t) 0);
     if (buffer != 0) {
        size_t have = strlen(buffer);
        size_t need = strlen(value) + have;
index 9be5fc254fb0e1bc6c1f30b86f35fb74e587dbc2..7b9533bd62f4aad519d8a9ff4b6684cf631ff90f 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 2001-2008,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -35,7 +35,7 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: varargs.c,v 1.12 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: varargs.c,v 1.13 2023/06/24 13:41:46 tom Exp $")
 
 #ifdef TRACE
 
@@ -59,18 +59,16 @@ typedef enum {
 NCURSES_EXPORT(char *)
 _nc_varargs(const char *fmt, va_list ap)
 {
-    static char dummy[] = "";
-
     char buffer[BUFSIZ];
     const char *param;
     int n;
 
     if (fmt == 0 || *fmt == '\0')
-       return dummy;
+       return NULL;
     if (MyLength == 0)
        MyBuffer = typeMalloc(char, MyLength = BUFSIZ);
     if (MyBuffer == 0)
-       return dummy;
+       return NULL;
     *MyBuffer = '\0';
 
     while (*fmt != '\0') {
@@ -185,7 +183,7 @@ _nc_varargs(const char *fmt, va_list ap)
        }
     }
 
-    return (MyBuffer ? MyBuffer : dummy);
+    return (MyBuffer ? MyBuffer : NULL);
 }
 #else
 EMPTY_MODULE(_nc_varargs)
index abb21cfddfe327a3ce58dc062756e8f8071ab926..d66aa9946594b1184d8da2093c797a1c6ed2db9a 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 1998-2015,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -148,7 +148,7 @@ AUTHOR
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: hardscroll.c,v 1.54 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: hardscroll.c,v 1.56 2023/06/24 22:55:24 tom Exp $")
 
 #if defined(SCROLLDEBUG) || defined(HASHDEBUG)
 
@@ -204,13 +204,19 @@ NCURSES_SP_NAME(_nc_scroll_optimize) (NCURSES_SP_DCL0)
        int *new_oldnums = typeRealloc(int,
                                       (size_t) need_lines,
                                       oldnums(SP_PARM));
-       if (!new_oldnums)
+       if (!new_oldnums) {
+           TR(TRACE_ICALLS, (T_RETURN("")));
            return;
+       }
        oldnums(SP_PARM) = new_oldnums;
        OLDNUM_SIZE(SP_PARM) = need_lines;
     }
     /* calculate the indices */
     NCURSES_SP_NAME(_nc_hash_map) (NCURSES_SP_ARG);
+    if (SP_PARM->hashtab_len < screen_lines(SP_PARM)) {
+       TR(TRACE_ICALLS, (T_RETURN("")));
+       return;
+    }
 #endif
 #endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */
 
index ba3ee089a2c165e58262b07a8fe8b5087fcd3dc6..aa3a67c518e2c7faae726c9a9cbf0238504e2566 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2021,2022 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_mvcur.c,v 1.157 2022/08/20 18:28:58 tom Exp $")
+MODULE_ID("$Id: lib_mvcur.c,v 1.158 2023/06/24 17:34:43 tom Exp $")
 
 #define WANT_CHAR(sp, y, x) NewScreen(sp)->_line[y].text[x]    /* desired state */
 
@@ -675,7 +675,7 @@ relative_move(NCURSES_SP_DCLx
                 * and the time the structure WANT_CHAR would access has been
                 * updated.
                 */
-               if (ovw) {
+               if (ovw && to_y >= 0) {
                    int i;
 
                    for (i = 0; i < n; i++) {
@@ -690,7 +690,7 @@ relative_move(NCURSES_SP_DCLx
                        }
                    }
                }
-               if (ovw) {
+               if (ovw && to_y >= 0) {
                    int i;
 
                    for (i = 0; i < n; i++)
index 91a849566fbb067e6e908717c9cde26f16279801..4356b0ebd7b2a778c42b3c6ea40e5dba2c9d18f7 100644 (file)
@@ -1,8 +1,8 @@
-ncurses6 (6.4+20230617) unstable; urgency=low
+ncurses6 (6.4+20230624) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 17 Jun 2023 05:47:23 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 24 Jun 2023 06:06:22 -0400
 
 ncurses6 (5.9+20131005) unstable; urgency=low
 
index 91a849566fbb067e6e908717c9cde26f16279801..4356b0ebd7b2a778c42b3c6ea40e5dba2c9d18f7 100644 (file)
@@ -1,8 +1,8 @@
-ncurses6 (6.4+20230617) unstable; urgency=low
+ncurses6 (6.4+20230624) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 17 Jun 2023 05:47:23 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 24 Jun 2023 06:06:22 -0400
 
 ncurses6 (5.9+20131005) unstable; urgency=low
 
index 95e7bef958fe76c3ff3ca76f15c4cdca0212705f..8783d4d06dbb414821b3ca41b797edaa5918df4f 100644 (file)
@@ -1,8 +1,8 @@
-ncurses6 (6.4+20230617) unstable; urgency=low
+ncurses6 (6.4+20230624) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 17 Jun 2023 05:47:23 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 24 Jun 2023 06:06:22 -0400
 
 ncurses6 (5.9+20120608) unstable; urgency=low
 
index 27eeed77858b0888b86eaef90d1091fb67ecd7e9..7abb61605c66228193993fb400cbdd8e53318f64 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: mingw-ncurses.nsi,v 1.590 2023/06/17 09:47:23 tom Exp $\r
+; $Id: mingw-ncurses.nsi,v 1.591 2023/06/24 10:06:22 tom Exp $\r
 \r
 ; TODO add examples\r
 ; TODO bump ABI to 6\r
@@ -10,7 +10,7 @@
 !define VERSION_MAJOR "6"\r
 !define VERSION_MINOR "4"\r
 !define VERSION_YYYY  "2023"\r
-!define VERSION_MMDD  "0617"\r
+!define VERSION_MMDD  "0624"\r
 !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD}\r
 \r
 !define MY_ABI   "5"\r
index 6f006b0da33c6c26d140e6a8e8c2130d820345dc..822402920b938f525a068d18945cece40e03e3db 100644 (file)
@@ -3,7 +3,7 @@
 Summary: shared libraries for terminal handling
 Name: mingw32-ncurses6
 Version: 6.4
-Release: 20230617
+Release: 20230624
 License: X11
 Group: Development/Libraries
 URL: https://invisible-island.net/ncurses/
index b3ee64427d33842263a3b4411bbcd677995f10cc..8b541eea769c0d51d4821e9d0b8f702bf124130b 100644 (file)
@@ -1,7 +1,7 @@
 Summary: shared libraries for terminal handling
 Name: ncurses6
 Version: 6.4
-Release: 20230617
+Release: 20230624
 License: X11
 Group: Development/Libraries
 URL: https://invisible-island.net/ncurses/
index 11d3e1d174213638bad77d69495d18eba4e8ccf4..dc459b77793984e09c768cc573b71023134657e7 100644 (file)
@@ -1,7 +1,7 @@
 Summary: Curses library with POSIX thread support.
 Name: ncursest6
 Version: 6.4
-Release: 20230617
+Release: 20230624
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
index 44d60dc936730f4c5e412c04ed0be79b9d97b76e..bb81263891196110d39541dd19053b4c82e8cfb8 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2020,2022 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 2002-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: demo_defkey.c,v 1.33 2022/12/10 23:31:31 tom Exp $
+ * $Id: demo_defkey.c,v 1.34 2023/06/24 15:37:17 tom Exp $
  *
  * Demonstrate the define_key() function.
  * Thomas Dickey - 2002/11/23
@@ -100,7 +100,7 @@ visible(const char *string)
 {
     char *result = 0;
 
-    if (string != 0 && *string != '\0') {
+    if (VALID_STRING(string) && *string != '\0') {
        int pass;
        int n;
        size_t need = 1;
@@ -185,7 +185,7 @@ duplicate(WINDOW *win, NCURSES_CONST char *name, int code)
 {
     char *value = tigetstr(name);
 
-    if (value != 0) {
+    if (VALID_STRING(value)) {
        const char *prefix = 0;
 
        if (!(strncmp) (value, "\033[", (size_t) 2)) {
index ee54b856998fb0ad44f2af758ab965fc3a40d648..96b02e14f355e29fcb448dc6ce003720a936dd0a 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2021,2022 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 2016,2017 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: list_keys.c,v 1.31 2022/12/10 23:23:27 tom Exp $
+ * $Id: list_keys.c,v 1.32 2023/06/24 13:57:11 tom Exp $
  *
  * Author: Thomas E Dickey
  *
@@ -71,6 +71,13 @@ typedef struct {
 #define Type(n) list[n].type
 #define Name(n) list[n].name
 
+static void
+failed(const char *msg)
+{
+    perror(msg);
+    ExitProgram(EXIT_FAILURE);
+}
+
 static const char *
 full_name(const char *name)
 {
@@ -338,8 +345,11 @@ list_keys(TERMINAL **terms, int count)
        widths1 = (int) strlen(modifier);
 
     for (k = 0; k < count; ++k) {
+       char *value;
        set_curterm(terms[k]);
-       check = (int) strlen(termname());
+       if ((value = termname()) == NULL)
+           failed("termname");
+       check = (int) strlen(value);
        if (widths2 < check)
            widths2 = check;
     }
index d003dfa32cab57a6914e29c8b4aad9428d0523dc..72b20cfb0c1da7d018101329acab146b6d98457d 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019-2020,2022 Thomas E. Dickey                                *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
  * Copyright 2017 Free Software Foundation, Inc.                            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,7 +28,7 @@
  ****************************************************************************/
 
 /*
- * $Id: sp_tinfo.c,v 1.28 2022/12/10 23:23:27 tom Exp $
+ * $Id: sp_tinfo.c,v 1.29 2023/06/24 14:14:56 tom Exp $
  *
  * TOTO: add option for non-sp-funcs interface
  */
@@ -339,8 +339,12 @@ main(int argc, char *argv[])
     do_stuff(my_out);
     do_stuff(my_err);
 
-    cleanup(my_out);
-    cleanup(my_err);
+    if (my_out != my_err) {
+       cleanup(my_out);
+       cleanup(my_err);
+    } else {
+       cleanup(my_out);
+    }
 
     ExitProgram(EXIT_SUCCESS);
 }
index 4e53c2e7c0cfcb54f0a5d7499821f7271a49385a..24d7c46c7773846b1b5c83f6ce0fc498f0182a2d 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020,2022 Thomas E. Dickey                                     *
+ * Copyright 2020-2022,2023 Thomas E. Dickey                                *
  * Copyright 2015,2016 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -30,7 +30,7 @@
 /*
  * Author: Thomas E. Dickey
  *
- * $Id: test_setupterm.c,v 1.16 2022/12/10 23:23:27 tom Exp $
+ * $Id: test_setupterm.c,v 1.17 2023/06/24 14:19:52 tom Exp $
  *
  * A simple demo of setupterm/restartterm.
  */
@@ -48,6 +48,13 @@ static TERMINAL **saved_terminals;
 static size_t num_saved;
 static size_t max_saved;
 
+static void
+failed(const char *msg)
+{
+    perror(msg);
+    ExitProgram(EXIT_FAILURE);
+}
+
 static void
 finish(int code)
 {
@@ -73,6 +80,8 @@ save_curterm(void)
        if (num_saved + 1 >= max_saved) {
            max_saved += 100;
            saved_terminals = typeRealloc(TERMINAL *, max_saved, saved_terminals);
+           if (saved_terminals == NULL)
+               failed("realloc");
        }
        saved_terminals[num_saved++] = cur_term;
     }