From 75290643f6f2a873a5f085ad876198b57485c398 Mon Sep 17 00:00:00 2001 From: millert Date: Thu, 21 Apr 2022 17:50:29 +0000 Subject: [PATCH] v_event_get: check qp->output for NULL before passing to e_memcmp(). Other users of qp->output already include a NULL check. Avoids a crash when cursor key support is disabled in cl/cl_term.c. From Jeremy Mates. OK tb@ --- usr.bin/vi/common/key.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr.bin/vi/common/key.c b/usr.bin/vi/common/key.c index e3a85e2e7f7..8b14269c598 100644 --- a/usr.bin/vi/common/key.c +++ b/usr.bin/vi/common/key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key.c,v 1.19 2017/04/18 01:45:35 deraadt Exp $ */ +/* $OpenBSD: key.c,v 1.20 2022/04/21 17:50:29 millert Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -650,7 +650,10 @@ not_digit: argp->e_c = CH_NOT_DIGIT; } /* Find out if the initial segments are identical. */ - init_nomap = !e_memcmp(qp->output, &gp->i_event[gp->i_next], qp->ilen); + if (qp->output != NULL) { + init_nomap = + !e_memcmp(qp->output, &gp->i_event[gp->i_next], qp->ilen); + } /* Delete the mapped characters from the queue. */ QREM(qp->ilen); -- 2.20.1