summaryrefslogtreecommitdiff
path: root/lib/libterm/termcap.c
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>1996-06-21 04:48:13 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>1996-06-21 04:48:13 +0000
commit5eddc12ca841772beab6f125d45aaa4873059c09 (patch)
treec169615c4ab7f1ebb53bde87d20399c7a9783031 /lib/libterm/termcap.c
parentf7e18851211b7e33476068a7d21d25313c19e56b (diff)
Accept a NULL buffer to tgetent(3)
Diffstat (limited to 'lib/libterm/termcap.c')
-rw-r--r--lib/libterm/termcap.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libterm/termcap.c b/lib/libterm/termcap.c
index 2109744f990..2eb5d31cdd9 100644
--- a/lib/libterm/termcap.c
+++ b/lib/libterm/termcap.c
@@ -139,16 +139,18 @@ tgetent(bp, name)
dummy = NULL;
i = cgetent(&dummy, pathvec, name);
- if (i == 0) {
+ if (i == 0 && bp != NULL) {
strncpy(bp, dummy, 1023);
bp[1023] = '\0';
if ((cp = strrchr(bp, ':')) != NULL)
if (cp[1] != '\0')
cp[1] = '\0';
}
-
- if (dummy)
+ else if (i == 0 && bp == NULL)
+ tbuf = dummy;
+ else if (dummy != NULL)
free(dummy);
+
/* no tc reference loop return code in libterm XXX */
if (i == -3)
return (-1);