Don't dereference NULL pointers when formatting missing denominators,
authorschwarze <schwarze@openbsd.org>
Thu, 1 Jan 2015 15:34:43 +0000 (15:34 +0000)
committerschwarze <schwarze@openbsd.org>
Thu, 1 Jan 2015 15:34:43 +0000 (15:34 +0000)
subscripts, superscripts, or "from" or "to" arguments.
Found by jsg@ with afl.

14 files changed:
regress/usr.bin/mandoc/eqn/fromto/Makefile
regress/usr.bin/mandoc/eqn/fromto/noarg.in [new file with mode: 0644]
regress/usr.bin/mandoc/eqn/fromto/noarg.out_ascii [new file with mode: 0644]
regress/usr.bin/mandoc/eqn/fromto/noarg.out_html [new file with mode: 0644]
regress/usr.bin/mandoc/eqn/over/Makefile
regress/usr.bin/mandoc/eqn/over/noarg.in [new file with mode: 0644]
regress/usr.bin/mandoc/eqn/over/noarg.out_ascii [new file with mode: 0644]
regress/usr.bin/mandoc/eqn/over/noarg.out_html [new file with mode: 0644]
regress/usr.bin/mandoc/eqn/over/noarg.out_lint [new file with mode: 0644]
regress/usr.bin/mandoc/eqn/subsup/Makefile
regress/usr.bin/mandoc/eqn/subsup/noarg.in [new file with mode: 0644]
regress/usr.bin/mandoc/eqn/subsup/noarg.out_ascii [new file with mode: 0644]
regress/usr.bin/mandoc/eqn/subsup/noarg.out_html [new file with mode: 0644]
usr.bin/mandoc/eqn_term.c

index a48306f..a2012e8 100644 (file)
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.1.1.1 2015/01/01 12:53:46 schwarze Exp $
+# $OpenBSD: Makefile,v 1.2 2015/01/01 15:34:43 schwarze Exp $
 
-REGRESS_TARGETS         = basic
-HTML_TARGETS    = basic
+REGRESS_TARGETS         = basic noarg
+HTML_TARGETS    = basic noarg
 
 .include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/eqn/fromto/noarg.in b/regress/usr.bin/mandoc/eqn/fromto/noarg.in
new file mode 100644 (file)
index 0000000..e37d2e9
--- /dev/null
@@ -0,0 +1,12 @@
+.Dd January 1, 2015
+.Dt FROMTO-NOARG 1
+.Os OpenBSD
+.Sh NAME
+.Nm fromto-noarg
+.Nd vertical stacking lacks final argument
+.Sh DESCRIPTION
+initial text
+.EQ
+x from a to to
+.EN
+final text
diff --git a/regress/usr.bin/mandoc/eqn/fromto/noarg.out_ascii b/regress/usr.bin/mandoc/eqn/fromto/noarg.out_ascii
new file mode 100644 (file)
index 0000000..06d2ae8
--- /dev/null
@@ -0,0 +1,9 @@
+FROMTO-NOARG(1)             General Commands Manual            FROMTO-NOARG(1)
+
+N\bNA\bAM\bME\bE
+     f\bfr\bro\bom\bmt\bto\bo-\b-n\bno\boa\bar\brg\bg - vertical stacking lacks final argument
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+     initial text x_a^^ final text
+
+OpenBSD                         January 1, 2015                        OpenBSD
diff --git a/regress/usr.bin/mandoc/eqn/fromto/noarg.out_html b/regress/usr.bin/mandoc/eqn/fromto/noarg.out_html
new file mode 100644 (file)
index 0000000..1caf3a3
--- /dev/null
@@ -0,0 +1 @@
+<mrow><munderover><mi>x</mi><mover><mi>a</mi></mover></munderover></mrow>
index 1933faf..8b864c2 100644 (file)
@@ -1,6 +1,7 @@
-# $OpenBSD: Makefile,v 1.1.1.1 2015/01/01 12:53:46 schwarze Exp $
+# $OpenBSD: Makefile,v 1.2 2015/01/01 15:34:43 schwarze Exp $
 
-REGRESS_TARGETS         = precedence
-HTML_TARGETS    = precedence
+REGRESS_TARGETS         = noarg precedence
+HTML_TARGETS    = noarg precedence
+LINT_TARGETS    = noarg
 
 .include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/eqn/over/noarg.in b/regress/usr.bin/mandoc/eqn/over/noarg.in
new file mode 100644 (file)
index 0000000..ac93fcc
--- /dev/null
@@ -0,0 +1,12 @@
+.Dd January 1, 2015
+.Dt OVER-NOARG 1
+.Os OpenBSD
+.Sh NAME
+.Nm over-noarg
+.Nd fraction operator without arguments
+.Sh DESCRIPTION
+initial text
+.EQ
+over over
+.EN
+final text
diff --git a/regress/usr.bin/mandoc/eqn/over/noarg.out_ascii b/regress/usr.bin/mandoc/eqn/over/noarg.out_ascii
new file mode 100644 (file)
index 0000000..4057f6b
--- /dev/null
@@ -0,0 +1,9 @@
+OVER-NOARG(1)               General Commands Manual              OVER-NOARG(1)
+
+N\bNA\bAM\bME\bE
+     o\bov\bve\ber\br-\b-n\bno\boa\bar\brg\bg - fraction operator without arguments
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+     initial text // final text
+
+OpenBSD                         January 1, 2015                        OpenBSD
diff --git a/regress/usr.bin/mandoc/eqn/over/noarg.out_html b/regress/usr.bin/mandoc/eqn/over/noarg.out_html
new file mode 100644 (file)
index 0000000..565b988
--- /dev/null
@@ -0,0 +1 @@
+<mrow><mfrac><mfrac><mi></mi></mfrac></mfrac></mrow>
diff --git a/regress/usr.bin/mandoc/eqn/over/noarg.out_lint b/regress/usr.bin/mandoc/eqn/over/noarg.out_lint
new file mode 100644 (file)
index 0000000..aabfc30
--- /dev/null
@@ -0,0 +1 @@
+mandoc: noarg.in:9:1: WARNING: missing eqn box, using "": over
index 2229958..4e11b33 100644 (file)
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.1.1.1 2015/01/01 12:53:46 schwarze Exp $
+# $OpenBSD: Makefile,v 1.2 2015/01/01 15:34:43 schwarze Exp $
 
-REGRESS_TARGETS         = combine sub_group
-HTML_TARGETS    = combine sub_group
+REGRESS_TARGETS         = combine noarg sub_group
+HTML_TARGETS    = combine noarg sub_group
 
 .include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/eqn/subsup/noarg.in b/regress/usr.bin/mandoc/eqn/subsup/noarg.in
new file mode 100644 (file)
index 0000000..adc32d8
--- /dev/null
@@ -0,0 +1,12 @@
+.Dd January 1, 2015
+.Dt SUBSUP-NOARG 1
+.Os OpenBSD
+.Sh NAME
+.Nm subsup-noarg
+.Nd empty subscripts and superscripts
+.Sh DESCRIPTION
+initial text
+.EQ
+x sub 1 sup sup
+.EN
+final text
diff --git a/regress/usr.bin/mandoc/eqn/subsup/noarg.out_ascii b/regress/usr.bin/mandoc/eqn/subsup/noarg.out_ascii
new file mode 100644 (file)
index 0000000..ad99680
--- /dev/null
@@ -0,0 +1,9 @@
+SUBSUP-NOARG(1)             General Commands Manual            SUBSUP-NOARG(1)
+
+N\bNA\bAM\bME\bE
+     s\bsu\bub\bbs\bsu\bup\bp-\b-n\bno\boa\bar\brg\bg - empty subscripts and superscripts
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+     initial text x_1^^ final text
+
+OpenBSD                         January 1, 2015                        OpenBSD
diff --git a/regress/usr.bin/mandoc/eqn/subsup/noarg.out_html b/regress/usr.bin/mandoc/eqn/subsup/noarg.out_html
new file mode 100644 (file)
index 0000000..0741689
--- /dev/null
@@ -0,0 +1 @@
+<mrow><msubsup><mi>x</mi><msup><mi>1</mi></msup></msubsup></mrow>
index 39324a7..e9a579c 100644 (file)
@@ -1,7 +1,7 @@
-/*     $OpenBSD: eqn_term.c,v 1.3 2014/10/12 14:48:25 schwarze Exp $ */
+/*     $OpenBSD: eqn_term.c,v 1.4 2015/01/01 15:34:43 schwarze Exp $ */
 /*
  * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -77,14 +77,17 @@ eqn_box(struct termp *p, const struct eqn_box *bp)
                     bp->pos == EQNPOS_TO) ? "^" : "_");
                p->flags |= TERMP_NOSPACE;
                child = child->next;
-               eqn_box(p, child);
-               if (bp->pos == EQNPOS_FROMTO ||
-                   bp->pos == EQNPOS_SUBSUP) {
-                       p->flags |= TERMP_NOSPACE;
-                       term_word(p, "^");
-                       p->flags |= TERMP_NOSPACE;
-                       child = child->next;
+               if (child != NULL) {
                        eqn_box(p, child);
+                       if (bp->pos == EQNPOS_FROMTO ||
+                           bp->pos == EQNPOS_SUBSUP) {
+                               p->flags |= TERMP_NOSPACE;
+                               term_word(p, "^");
+                               p->flags |= TERMP_NOSPACE;
+                               child = child->next;
+                               if (child != NULL)
+                                       eqn_box(p, child);
+                       }
                }
        } else {
                child = bp->first;