tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Kristaps Dzonsons <kristaps@bsd.lv>
To: tech@mdocml.bsd.lv
Subject: Crash in mandoc HEAD
Date: Fri, 15 Aug 2014 15:53:49 +0200	[thread overview]
Message-ID: <53EE10ED.5090400@bsd.lv> (raw)

[-- Attachment #1: Type: text/plain, Size: 555 bytes --]

Hi folks,

I managed to crash mandoc(1) today while formatting a manual.  Narrowed 
down:

      1	.Dd $Mdocdate$
      2	.Dt FOO 1
      3	.Os
      4	.Sh NAME
      5	.Nm foo
      6	.Nd bar
      7	.Sh DESCRIPTION
      8	The
      9	.Bl -hang
     10	.It Nm Fo o
     11	xyzzy
     12	.El

In short, the "Fo" is continuing a node subtree perpetually and the HEAD 
for the "It" on line 10 just keeps going.  There's a check for 
"n->next->child" which thus crashes because "n->next" is NULL.

The fix is very simple and enclosed.

Ok?

Best,

Kristaps

[-- Attachment #2: itcrash.diff --]
[-- Type: text/plain, Size: 614 bytes --]

Index: mdoc_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v
retrieving revision 1.276
diff -u -p -r1.276 mdoc_term.c
--- mdoc_term.c	10 Aug 2014 23:54:41 -0000	1.276
+++ mdoc_term.c	15 Aug 2014 13:53:07 -0000
@@ -806,7 +806,7 @@ termp_it_pre(DECL_ARGS)
 		 * the "overstep" effect in term_flushln() and treat
 		 * this as a `-ohang' list instead.
 		 */
-		if (n->next->child &&
+		if (NULL != n->next && NULL != n->next->child &&
 		    (MDOC_Bl == n->next->child->tok ||
 		     MDOC_Bd == n->next->child->tok))
 			break;

             reply	other threads:[~2014-08-15 13:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-15 13:53 Kristaps Dzonsons [this message]
2014-08-17  4:16 ` Ingo Schwarze

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53EE10ED.5090400@bsd.lv \
    --to=kristaps@bsd.lv \
    --cc=tech@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).