diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-07 02:24:16 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-07 02:24:16 +0000 |
commit | 2b6e1545e87510cb500f57376ef30c9fdd594591 (patch) | |
tree | c8df1d42254ff35dfc38b1a3156c8c9878189d25 /ext/tk/tkutil/tkutil.c | |
parent | 088d0a3b446460c5eb928a68e5da0e3d8b85391f (diff) | |
download | ruby-2b6e1545e87510cb500f57376ef30c9fdd594591.tar.gz |
tkutil.c: fix overrun
* ext/tk/tkutil/tkutil.c (cbsubst_initialize): fix out-of-bound
access when no arguments given. `p Tk::Event.new` crashed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/tkutil/tkutil.c')
-rw-r--r-- | ext/tk/tkutil/tkutil.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/ext/tk/tkutil/tkutil.c b/ext/tk/tkutil/tkutil.c index 147dfa23d1..3b1d3c5ecf 100644 --- a/ext/tk/tkutil/tkutil.c +++ b/ext/tk/tkutil/tkutil.c @@ -1284,11 +1284,13 @@ cbsubst_initialize(argc, argv, self) inf = cbsubst_get_ptr(rb_obj_class(self)); - idx = 0; - for(iv_idx = 0; iv_idx < CBSUBST_TBL_MAX; iv_idx++) { - if ( inf->ivar[iv_idx] == (ID) 0 ) continue; - rb_ivar_set(self, inf->ivar[iv_idx], argv[idx++]); - if (idx >= argc) break; + if (argc > 0) { + idx = 0; + for (iv_idx = 0; iv_idx < CBSUBST_TBL_MAX; iv_idx++) { + if (inf->ivar[iv_idx] == (ID)0) continue; + rb_ivar_set(self, inf->ivar[iv_idx], argv[idx++]); + if (idx >= argc) break; + } } return self; |