summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorKevin Backhouse <kevinbackhouse@github.com>2022-07-12 19:48:10 +0100
committerGitHub <noreply@github.com>2022-07-12 11:48:10 -0700
commit8c1808151f4c1b44e8b0fe935c571f05b2641b8b (patch)
treeed7dc9e5aac6945cae8df53e3f3ec1df6e120319 /parse.y
parent8309b1366c3307ab8d9cda5b61b91540cf6cc8aa (diff)
Fix some UBSAN false positives (#6115)
* Fix some UBSAN false positives. * ruby tool/update-deps --fix
Notes
Notes: Merged-By: jhawthorn <john@hawthorn.email>
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y6
1 files changed, 3 insertions, 3 deletions
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;
}