diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2018-08-16 15:05:34 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2018-08-16 15:05:34 +0000 |
commit | dd0d3dcce42380000f428a36e07f1c43cbe8b506 (patch) | |
tree | 0bcca992a37e1a9838ee355738957b53e7bd9ba6 /man_validate.c | |
parent | 0eda964d1aadc6a0e9d48b0b047de92144f8eec9 (diff) | |
download | mandoc-dd0d3dcce42380000f428a36e07f1c43cbe8b506.tar.gz |
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.c | 5 |
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) |