From c25ff7bb5d8e8d2985ec8fd32a7211a06ad4eca0 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Tue, 23 Jul 2019 08:42:20 +0100 Subject: check iseq is executable --- iseq.c | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/iseq.c b/iseq.c index 9ee8d41275..776576a52b 100644 --- a/iseq.c +++ b/iseq.c @@ -370,41 +370,41 @@ rb_iseq_memsize(const rb_iseq_t *iseq) /* TODO: should we count original_iseq? */ - if (body) { - struct rb_call_info_with_kwarg *ci_kw_entries = (struct rb_call_info_with_kwarg *)&body->ci_entries[body->ci_size]; + if (ISEQ_EXECUTABLE_P(iseq) && body) { + struct rb_call_info_with_kwarg *ci_kw_entries = (struct rb_call_info_with_kwarg *)&body->ci_entries[body->ci_size]; - size += sizeof(struct rb_iseq_constant_body); - size += body->iseq_size * sizeof(VALUE); - size += body->insns_info.size * (sizeof(struct iseq_insn_info_entry) + sizeof(unsigned int)); - size += body->local_table_size * sizeof(ID); - if (body->catch_table) { - size += iseq_catch_table_bytes(body->catch_table->size); - } - size += (body->param.opt_num + 1) * sizeof(VALUE); - size += param_keyword_size(body->param.keyword); + size += sizeof(struct rb_iseq_constant_body); + size += body->iseq_size * sizeof(VALUE); + size += body->insns_info.size * (sizeof(struct iseq_insn_info_entry) + sizeof(unsigned int)); + size += body->local_table_size * sizeof(ID); + if (body->catch_table) { + size += iseq_catch_table_bytes(body->catch_table->size); + } + size += (body->param.opt_num + 1) * sizeof(VALUE); + size += param_keyword_size(body->param.keyword); - /* body->is_entries */ - size += body->is_size * sizeof(union iseq_inline_storage_entry); + /* body->is_entries */ + size += body->is_size * sizeof(union iseq_inline_storage_entry); - /* body->ci_entries */ - size += body->ci_size * sizeof(struct rb_call_info); - size += body->ci_kw_size * sizeof(struct rb_call_info_with_kwarg); + /* body->ci_entries */ + size += body->ci_size * sizeof(struct rb_call_info); + size += body->ci_kw_size * sizeof(struct rb_call_info_with_kwarg); - /* body->cc_entries */ - size += body->ci_size * sizeof(struct rb_call_cache); - size += body->ci_kw_size * sizeof(struct rb_call_cache); + /* body->cc_entries */ + size += body->ci_size * sizeof(struct rb_call_cache); + size += body->ci_kw_size * sizeof(struct rb_call_cache); - if (ci_kw_entries) { - unsigned int i; + if (ci_kw_entries) { + unsigned int i; - for (i = 0; i < body->ci_kw_size; i++) { - const struct rb_call_info_kw_arg *kw_arg = ci_kw_entries[i].kw_arg; + for (i = 0; i < body->ci_kw_size; i++) { + const struct rb_call_info_kw_arg *kw_arg = ci_kw_entries[i].kw_arg; - if (kw_arg) { - size += rb_call_info_kw_arg_bytes(kw_arg->keyword_len); - } - } - } + if (kw_arg) { + size += rb_call_info_kw_arg_bytes(kw_arg->keyword_len); + } + } + } } compile_data = ISEQ_COMPILE_DATA(iseq); -- cgit v1.2.3