summaryrefslogtreecommitdiff
path: root/usr.bin/vi/cl
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2022-04-22 15:50:08 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2022-04-22 15:50:08 +0000
commita11949d4585506972dc41afab09621d052325af3 (patch)
tree9323c68e2e6e9315d84307b61cda3e681eed0b97 /usr.bin/vi/cl
parent077cae9afe0dc9193a028c2ba2d3fc8a10286cd3 (diff)
Check tkp->output != NULL before taking strlen for both command mappings
and input mappings. This adds a missing check for command mappings and simplifies the input mappings. ok millert
Diffstat (limited to 'usr.bin/vi/cl')
-rw-r--r--usr.bin/vi/cl/cl_term.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/usr.bin/vi/cl/cl_term.c b/usr.bin/vi/cl/cl_term.c
index c8b13f77fde..a4c396829f0 100644
--- a/usr.bin/vi/cl/cl_term.c
+++ b/usr.bin/vi/cl/cl_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cl_term.c,v 1.28 2017/07/20 08:37:48 anton Exp $ */
+/* $OpenBSD: cl_term.c,v 1.29 2022/04/22 15:50:07 tb Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -78,14 +78,18 @@ cl_term_init(SCR *sp)
{
SEQ *qp;
TKLIST const *tkp;
+ size_t output_len;
char *t;
/* Command mappings. */
for (tkp = c_tklist; tkp->name != NULL; ++tkp) {
if ((t = tigetstr(tkp->ts)) == NULL || t == (char *)-1)
continue;
+ output_len = 0;
+ if (tkp->output != NULL)
+ output_len = strlen(tkp->output);
if (seq_set(sp, tkp->name, strlen(tkp->name), t, strlen(t),
- tkp->output, strlen(tkp->output), SEQ_COMMAND,
+ tkp->output, output_len, SEQ_COMMAND,
SEQ_NOOVERWRITE | SEQ_SCREEN))
return (1);
}
@@ -103,16 +107,13 @@ cl_term_init(SCR *sp)
*/
if (!strcmp(t, "\b"))
continue;
- if (tkp->output == NULL) {
- if (seq_set(sp, tkp->name, strlen(tkp->name),
- t, strlen(t), NULL, 0,
- SEQ_INPUT, SEQ_NOOVERWRITE | SEQ_SCREEN))
- return (1);
- } else
- if (seq_set(sp, tkp->name, strlen(tkp->name),
- t, strlen(t), tkp->output, strlen(tkp->output),
- SEQ_INPUT, SEQ_NOOVERWRITE | SEQ_SCREEN))
- return (1);
+ output_len = 0;
+ if (tkp->output != NULL)
+ output_len = strlen(tkp->output);
+ if (seq_set(sp, tkp->name, strlen(tkp->name), t, strlen(t),
+ tkp->output, output_len, SEQ_INPUT,
+ SEQ_NOOVERWRITE | SEQ_SCREEN))
+ return (1);
}
/*