* mdocml: Don't deref NULL if the only child of the first .Sh is an empty
@ 2016-08-10 20:18 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2016-08-10 20:18 UTC (permalink / raw)
To: source
Log Message:
-----------
Don't deref NULL if the only child of the first .Sh is an empty
in-line macro, and don't printf("%s", NULL) if the first child
of the first .Sh is a macro; again found by tb@ with afl(1).
(No, you should never use macros in any .Sh at all, please.)
Modified Files:
--------------
mdocml:
mdoc_validate.c
Revision Data
-------------
Index: mdoc_validate.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_validate.c,v
retrieving revision 1.304
retrieving revision 1.305
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.304 -r1.305
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -1761,8 +1761,9 @@ post_sh_authors(POST_ARGS)
static void
post_sh_head(POST_ARGS)
{
- const char *goodsec;
- enum roff_sec sec;
+ struct roff_node *nch;
+ const char *goodsec;
+ enum roff_sec sec;
/*
* Process a new section. Sections are either "named" or
@@ -1778,8 +1779,10 @@ post_sh_head(POST_ARGS)
if (sec != SEC_NAME && mdoc->lastnamed == SEC_NONE)
mandoc_vmsg(MANDOCERR_NAMESEC_FIRST, mdoc->parse,
mdoc->last->line, mdoc->last->pos, "Sh %s",
- sec == SEC_CUSTOM ? mdoc->last->child->string :
- secnames[sec]);
+ sec != SEC_CUSTOM ? secnames[sec] :
+ (nch = mdoc->last->child) == NULL ? "" :
+ nch->type == ROFFT_TEXT ? nch->string :
+ mdoc_macronames[nch->tok]);
/* The SYNOPSIS gets special attention in other areas. */
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-08-10 20:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-10 20:18 mdocml: Don't deref NULL if the only child of the first .Sh is an empty schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).