Source-Changes-HG archive

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

[src/trunk]: src/lib/libterminfo Fix for PR lib/56298



details:   https://anonhg.NetBSD.org/src/rev/d94b11a6c098
branches:  trunk
changeset: 1027695:d94b11a6c098
user:      blymn <blymn%NetBSD.org@localhost>
date:      Wed Dec 15 21:07:12 2021 +0000

description:
Fix for PR lib/56298

Remove the DIAGASSERT for str being NULL in the puts/putp functions,
add protection so that the functions just return OK if str is NULL.
This prevents the assert firing when libcurses passes through a NULL
due to an undefined terminfo entry.

diffstat:

 lib/libterminfo/tputs.c |  11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diffs (54 lines):

diff -r 0f3887c33eb9 -r d94b11a6c098 lib/libterminfo/tputs.c
--- a/lib/libterminfo/tputs.c   Wed Dec 15 16:27:10 2021 +0000
+++ b/lib/libterminfo/tputs.c   Wed Dec 15 21:07:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tputs.c,v 1.5 2019/10/03 18:02:05 christos Exp $ */
+/* $NetBSD: tputs.c,v 1.6 2021/12/15 21:07:12 blymn Exp $ */
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: tputs.c,v 1.5 2019/10/03 18:02:05 christos Exp $");
+__RCSID("$NetBSD: tputs.c,v 1.6 2021/12/15 21:07:12 blymn Exp $");
 
 #include <assert.h>
 #include <ctype.h>
@@ -135,9 +135,11 @@
        char pc;
 
        _DIAGASSERT(term != NULL);
-       _DIAGASSERT(str != NULL);
        _DIAGASSERT(outc != NULL);
 
+       if (str == NULL)
+               return OK;
+
        dodelay = (str == t_bell(term) ||
            str == t_flash_screen(term) ||
            (t_xon_xoff(term) == 0 && t_padding_baud_rate(term) != 0));
@@ -155,7 +157,6 @@
 {
 
        _DIAGASSERT(term != NULL);
-       _DIAGASSERT(str != NULL);
        return ti_puts(term, str, 1,
            (int (*)(int, void *))(void *)putchar, NULL);
 }
@@ -164,7 +165,6 @@
 tputs(const char *str, int affcnt, int (*outc)(int))
 {
 
-       _DIAGASSERT(str != NULL);
        _DIAGASSERT(outc != NULL);
        return _ti_puts(1, ospeed, PC, str, affcnt,
            (int (*)(int, void *))(void *)outc, NULL);
@@ -174,6 +174,5 @@
 putp(const char *str)
 {
 
-       _DIAGASSERT(str != NULL);
        return tputs(str, 1, putchar);
 }



Home | Main Index | Thread Index | Old Index