From 40cc9231a9b37bfb22571a68fa0493e0ba532405 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 30 Oct 2014 06:33:11 +0000 Subject: tkutil.c: remove useless branches * ext/tk/tkutil/tkutil.c (cbsubst_table_setup): remove useless branches and get rid of out of bound access. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/tkutil/tkutil.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'ext') diff --git a/ext/tk/tkutil/tkutil.c b/ext/tk/tkutil/tkutil.c index da05191773..e9310244c8 100644 --- a/ext/tk/tkutil/tkutil.c +++ b/ext/tk/tkutil/tkutil.c @@ -1562,16 +1562,8 @@ cbsubst_table_setup(argc, argv, self) inf = RARRAY_PTR(key_inf)[idx]; if (!RB_TYPE_P(inf, T_ARRAY)) continue; - if (RB_TYPE_P(RARRAY_PTR(inf)[0], T_STRING)) { - chr = *(RSTRING_PTR(RARRAY_PTR(inf)[0])); - } else { - chr = NUM2CHR(RARRAY_PTR(inf)[0]); - } - if (RB_TYPE_P(RARRAY_PTR(inf)[1], T_STRING)) { - subst_inf->type[chr] = *(RSTRING_PTR(RARRAY_PTR(inf)[1])); - } else { - subst_inf->type[chr] = NUM2CHR(RARRAY_PTR(inf)[1]); - } + chr = NUM2CHR(RARRAY_PTR(inf)[0]); + subst_inf->type[chr] = NUM2CHR(RARRAY_PTR(inf)[1]); subst_inf->full_subst_length += 3; @@ -1606,11 +1598,7 @@ cbsubst_table_setup(argc, argv, self) subst_inf->key[chr][RSTRING_LEN(RARRAY_PTR(inf)[0])] = '\0'; } #endif - if (RB_TYPE_P(RARRAY_PTR(inf)[1], T_STRING)) { - subst_inf->type[chr] = *(RSTRING_PTR(RARRAY_PTR(inf)[1])); - } else { - subst_inf->type[chr] = NUM2CHR(RARRAY_PTR(inf)[1]); - } + subst_inf->type[chr] = NUM2CHR(RARRAY_PTR(inf)[1]); subst_inf->full_subst_length += (subst_inf->keylen[chr] + 2); -- cgit v1.2.3