Module Name: src
Committed By: blymn
Date: Wed Dec 15 21:07:12 UTC 2021
Modified Files:
src/lib/libterminfo: tputs.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libterminfo/tputs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libterminfo/tputs.c
diff -u src/lib/libterminfo/tputs.c:1.5 src/lib/libterminfo/tputs.c:1.6
--- src/lib/libterminfo/tputs.c:1.5 Thu Oct 3 18:02:05 2019
+++ src/lib/libterminfo/tputs.c Wed Dec 15 21:07:12 2021
@@ -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 @@ ti_puts(const TERMINAL *term, const char
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 @@ ti_putp(const TERMINAL *term, const char
{
_DIAGASSERT(term != NULL);
- _DIAGASSERT(str != NULL);
return ti_puts(term, str, 1,
(int (*)(int, void *))(void *)putchar, NULL);
}
@@ -164,7 +165,6 @@ int
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 @@ int
putp(const char *str)
{
- _DIAGASSERT(str != NULL);
return tputs(str, 1, putchar);
}