fix reliability issue.

if wcwidth(3) return -1, nvi may crash by memory fault.
This commit is contained in:
tnozaki 2009-04-19 02:28:19 +00:00
parent c7dd380491
commit 41a9bd5969
2 changed files with 4 additions and 4 deletions

View File

@ -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))

View File

@ -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