From 0f02fbd9ffc0c26fa160505872a6c0d0b0493028 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 9 Nov 2023 16:39:49 +0900 Subject: Range check in pm_constant_id_lookup --- prism_compile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/prism_compile.c b/prism_compile.c index dd8cdd9222..b5dc08f074 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -719,6 +719,9 @@ pm_lookup_local_index_with_depth(rb_iseq_t *iseq, pm_scope_node_t *scope_node, p static ID pm_constant_id_lookup(pm_scope_node_t *scope_node, pm_constant_id_t constant_id) { + if (constant_id < 1 || constant_id > scope_node->parser->constant_pool.size) { + rb_raise(rb_eArgError, "[PRISM] constant_id out of range: %u", (unsigned int)constant_id); + } return scope_node->constants[constant_id - 1]; } -- cgit v1.2.3