fix reliability issue.
if wcwidth(3) return -1, nvi may crash by memory fault.
This commit is contained in:
parent
c7dd380491
commit
41a9bd5969
4
dist/nvi/common/conv.h
vendored
4
dist/nvi/common/conv.h
vendored
@ -1,8 +1,8 @@
|
||||
/* $NetBSD: conv.h,v 1.3 2009/01/18 03:43:45 lukem Exp $ */
|
||||
/* $NetBSD: conv.h,v 1.4 2009/04/19 02:28:19 tnozaki Exp $ */
|
||||
|
||||
#define KEY_COL(sp, ch) \
|
||||
(INTISWIDE(ch) ? \
|
||||
(size_t)CHAR_WIDTH(sp, ch) ? \
|
||||
(CHAR_WIDTH(sp, ch) >= 0) ? \
|
||||
(size_t)CHAR_WIDTH(sp, ch) : 1 /* extra space */ \
|
||||
: KEY_LEN(sp,ch))
|
||||
|
||||
|
4
dist/nvi/vi/vs_line.c
vendored
4
dist/nvi/vi/vs_line.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vs_line.c,v 1.4 2009/01/18 03:45:50 lukem Exp $ */
|
||||
/* $NetBSD: vs_line.c,v 1.5 2009/04/19 02:28:19 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993, 1994
|
||||
@ -442,7 +442,7 @@ display:
|
||||
/* XXXX this needs some rethinking */
|
||||
if (INTISWIDE(ch)) {
|
||||
/* Put a space before non-spacing char. */
|
||||
if (!CHAR_WIDTH(sp, ch))
|
||||
if (CHAR_WIDTH(sp, ch) <= 0)
|
||||
*cbp++ = L(' ');
|
||||
*cbp++ = ch;
|
||||
} else
|
||||
|
Loading…
Reference in New Issue
Block a user