summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/roff.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2010-11-27 20:52:35 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2010-11-27 20:52:35 +0000
commite0a999f16a0cb3e47000dcfb2df9116625977141 (patch)
tree4a1bfbfbfddc07a5384c7f0a40ed4eed0f63ff57 /usr.bin/mandoc/roff.c
parent1cb03087686bf9f85bf8cc3898231f75ed28fa67 (diff)
Two related bugfixes:
1) When using a user-defined string of length 0 as a macro, do not access memory before the start of the string (segfault). 2) When beginning to define a user-defined macro, initialize the string representing the macro to the empty string, not to the NULL pointer, such that, in case the macro turns out to not have any content, like in .de IX .. the macro will be defined and empty instead of undefined. This avoids large numbers of bogus mandoc ERROR messages about undefined macros (which are actually defined and empty), in particular in man(7) code generated from pod2man(1), for example in Perl and OpenSSL.
Diffstat (limited to 'usr.bin/mandoc/roff.c')
-rw-r--r--usr.bin/mandoc/roff.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index 8c5973e7307..a9bc0937dca 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.18 2010/11/25 23:07:58 schwarze Exp $ */
+/* $Id: roff.c,v 1.19 2010/11/27 20:52:34 schwarze Exp $ */
/*
* Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -642,7 +642,7 @@ roff_block(ROFF_ARGS)
* added from roff_block_text() in multiline mode.
*/
if (ROFF_de == tok)
- roff_setstr(r, name, NULL, 0);
+ roff_setstr(r, name, "", 0);
if ('\0' == (*bufp)[pos])
return(ROFF_IGN);
@@ -1140,7 +1140,7 @@ roff_userdef(ROFF_ARGS)
if (0 == *szp)
*szp = strlen(*bufp) + 1;
- return(*szp && '\n' == (*bufp)[(int)*szp - 2] ?
+ return(*szp > 1 && '\n' == (*bufp)[(int)*szp - 2] ?
ROFF_REPARSE : ROFF_APPEND);
}