From 8c1808151f4c1b44e8b0fe935c571f05b2641b8b Mon Sep 17 00:00:00 2001 From: Kevin Backhouse Date: Tue, 12 Jul 2022 19:48:10 +0100 Subject: Fix some UBSAN false positives (#6115) * Fix some UBSAN false positives. * ruby tool/update-deps --fix --- parse.y | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'parse.y') diff --git a/parse.y b/parse.y index 081fc1c868..b4c3106b8c 100644 --- a/parse.y +++ b/parse.y @@ -232,12 +232,12 @@ enum { }; #define NUMPARAM_ID_P(id) numparam_id_p(id) -#define NUMPARAM_ID_TO_IDX(id) (unsigned int)(((id) >> ID_SCOPE_SHIFT) - tNUMPARAM_1 + 1) -#define NUMPARAM_IDX_TO_ID(idx) TOKEN2LOCALID((tNUMPARAM_1 + (idx) - 1)) +#define NUMPARAM_ID_TO_IDX(id) (unsigned int)(((id) >> ID_SCOPE_SHIFT) - (tNUMPARAM_1 - 1)) +#define NUMPARAM_IDX_TO_ID(idx) TOKEN2LOCALID((tNUMPARAM_1 - 1 + (idx))) static int numparam_id_p(ID id) { - if (!is_local_id(id)) return 0; + if (!is_local_id(id) || id < (tNUMPARAM_1 << ID_SCOPE_SHIFT)) return 0; unsigned int idx = NUMPARAM_ID_TO_IDX(id); return idx > 0 && idx <= NUMPARAM_MAX; } -- cgit v1.2.3