summaryrefslogtreecommitdiffstats
path: root/mdoc_macro.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2012-11-19 22:30:58 +0000
committerIngo Schwarze <schwarze@openbsd.org>2012-11-19 22:30:58 +0000
commite72db3dd30f49f9ba66d3343bd9b16314f1a8a71 (patch)
tree8974505c93691ab13914eaa1cc57cb7c64e2703f /mdoc_macro.c
parentf54547a9a73ceac08c89c5a0084f6fcb01900892 (diff)
downloadmandoc-e72db3dd30f49f9ba66d3343bd9b16314f1a8a71.tar.gz
Do not crash on stray .Ta macros found outside column lists.
Problem reported by jmc@, thanks.
Diffstat (limited to 'mdoc_macro.c')
-rw-r--r--mdoc_macro.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/mdoc_macro.c b/mdoc_macro.c
index e946d7ab..e7ccd62f 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1759,16 +1759,22 @@ phrase(struct mdoc *mdoc, int line, int ppos, char *buf)
static int
phrase_ta(MACRO_PROT_ARGS)
{
+ struct mdoc_node *n;
int la;
enum mdoct ntok;
enum margserr ac;
char *p;
- /*
- * FIXME: this is overly restrictive: if the `Ta' is unexpected,
- * it should simply error out with ARGSLOST.
- */
+ /* Make sure we are in a column list or ignore this macro. */
+ n = mdoc->last;
+ while (NULL != n && MDOC_Bl != n->tok)
+ n = n->parent;
+ if (NULL == n || LIST_column != n->norm->Bl.type) {
+ mdoc_pmsg(mdoc, line, ppos, MANDOCERR_STRAYTA);
+ return(1);
+ }
+ /* Advance to the next column. */
if ( ! rew_sub(MDOC_BODY, mdoc, MDOC_It, line, ppos))
return(0);
if ( ! mdoc_body_alloc(mdoc, line, ppos, MDOC_It))