From 99622f1b4d341ddc21f96b55ae3addf4013cfb97 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Thu, 16 Aug 2018 15:05:34 +0000 Subject: 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. --- man_validate.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'man_validate.c') 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) -- cgit v1.2.3-56-ge451