aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/man_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-08-16 15:05:34 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-08-16 15:05:34 +0000
commit99622f1b4d341ddc21f96b55ae3addf4013cfb97 (patch)
treeef1b993efba82eef8656ad17b5d38c823630453a /man_validate.c
parent9d418b3494affa0a03b36bef60ebd4f9074c194b (diff)
downloadmandoc-99622f1b4d341ddc21f96b55ae3addf4013cfb97.tar.gz
mandoc-99622f1b4d341ddc21f96b55ae3addf4013cfb97.tar.zst
mandoc-99622f1b4d341ddc21f96b55ae3addf4013cfb97.zip
Do not calculate a pointer to a memory location before the beginning of
a static array. Christos Zoulas, Robert Elz, and Andreas Gustafsson point out that is undefined behaviour by the C standard even if we never access the pointer.
Diffstat (limited to 'man_validate.c')
-rw-r--r--man_validate.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/man_validate.c b/man_validate.c
index d6c51af5..8e2f6bee 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -54,7 +54,7 @@ static void post_UR(CHKARGS);
static void post_in(CHKARGS);
static void post_vs(CHKARGS);
-static const v_check __man_valids[MAN_MAX - MAN_TH] = {
+static const v_check man_valids[MAN_MAX - MAN_TH] = {
post_TH, /* TH */
NULL, /* SH */
NULL, /* SS */
@@ -92,7 +92,6 @@ static const v_check __man_valids[MAN_MAX - MAN_TH] = {
post_UR, /* MT */
NULL, /* ME */
};
-static const v_check *man_valids = __man_valids - MAN_TH;
void
@@ -138,7 +137,7 @@ man_node_validate(struct roff_man *man)
break;
}
assert(n->tok >= MAN_TH && n->tok < MAN_MAX);
- cp = man_valids + n->tok;
+ cp = man_valids + (n->tok - MAN_TH);
if (*cp)
(*cp)(man, n);
if (man->last == n)