summaryrefslogtreecommitdiffstats
path: root/mdoc_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-08-01 13:46:15 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-08-01 13:46:15 +0000
commit160e978ed219fefc76edebd7f7d3ed55ed7e74fd (patch)
tree54ca67df1335486e9ccfb09fce8285d90d843c8b /mdoc_validate.c
parentf5da3327ebbc63db1b7c9b2660235b22740f301b (diff)
downloadmandoc-160e978ed219fefc76edebd7f7d3ed55ed7e74fd.tar.gz
Avoid a read access one byte beyond the end of an allocated string
which occurred in situations like ".Fl a Cm --"; found by Leah Neukirchen <leah at vuxu dot org> with valgrind on Void Linux.
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 05d78391..5ab5f3ae 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -440,7 +440,7 @@ check_text_em(struct roff_man *mdoc, int ln, int pos, char *p)
np->string != '\0' &&
isalpha((unsigned char)np->string[
strlen(np->string) - 1])) ||
- (cp[2] != '\0' ?
+ (cp[1] != '\0' && cp[2] != '\0' ?
isalpha((unsigned char)cp[2]) :
nn != NULL &&
nn->type == ROFFT_TEXT &&