From 0c662b34313699223f08df54c5dcd8c481ff8a95 Mon Sep 17 00:00:00 2001 From: normal Date: Wed, 3 Dec 2014 22:03:59 +0000 Subject: iseq.c: avoid segfault on incomplete iseq Compile failures will trigger iseq_free before iseq->callinfo_entries are allocated at all. * iseq.c (iseq_free): avoid segfault on incomplete iseq * test/ruby/test_syntax.rb (test_invalid_next): new test for syntax error, not segfault git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- iseq.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'iseq.c') diff --git a/iseq.c b/iseq.c index 6774ba3253..655bb64ef8 100644 --- a/iseq.c +++ b/iseq.c @@ -79,12 +79,14 @@ iseq_free(void *ptr) RUBY_FREE_UNLESS_NULL(iseq->line_info_table); RUBY_FREE_UNLESS_NULL(iseq->local_table); RUBY_FREE_UNLESS_NULL(iseq->is_entries); - for (i=0; icallinfo_size; i++) { - /* TODO: revisit callinfo data structure */ - rb_call_info_kw_arg_t *kw_arg = iseq->callinfo_entries[i].kw_arg; - RUBY_FREE_UNLESS_NULL(kw_arg); + if (iseq->callinfo_entries) { + for (i=0; icallinfo_size; i++) { + /* TODO: revisit callinfo data structure */ + rb_call_info_kw_arg_t *kw_arg = iseq->callinfo_entries[i].kw_arg; + RUBY_FREE_UNLESS_NULL(kw_arg); + } + RUBY_FREE_UNLESS_NULL(iseq->callinfo_entries); } - RUBY_FREE_UNLESS_NULL(iseq->callinfo_entries); RUBY_FREE_UNLESS_NULL(iseq->catch_table); RUBY_FREE_UNLESS_NULL(iseq->param.opt_table); if (iseq->param.keyword != NULL) { -- cgit v1.2.3