diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-10-03 00:11:03 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-10-03 10:47:24 +0900 |
commit | 5a665f6ce796730b9b81a27e418fdba49b5f83b7 (patch) | |
tree | 7e9fc2df95a68229d302db4cc9db56c510eb525e /compile.c | |
parent | 6aa466ba9cf3a0a597716bf7584735ca980622d0 (diff) |
Check builtin inline function index overflow
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -7294,7 +7294,7 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co return COMPILE_NG; } else { - char inline_func[0x20]; + char inline_func[DECIMAL_SIZE_OF_BITS(sizeof(int) * CHAR_BIT) + 1]; bool cconst = false; retry:; const struct rb_builtin_function *bf = iseq_builtin_function_lookup(iseq, builtin_func); @@ -7325,8 +7325,11 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co return COMPILE_NG; } + if (GET_VM()->builtin_inline_index == INT_MAX) { + rb_bug("builtin inline function index overflow:%s", builtin_func); + } int inline_index = GET_VM()->builtin_inline_index++; - snprintf(inline_func, 0x20, "_bi%d", inline_index); + snprintf(inline_func, sizeof(inline_func), "_bi%d", inline_index); builtin_func = inline_func; args_node = NULL; goto retry; |