summaryrefslogtreecommitdiff
path: root/ext/tk/tkutil/tkutil.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-30 06:33:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-30 06:33:11 +0000
commit40cc9231a9b37bfb22571a68fa0493e0ba532405 (patch)
tree111d5008bb0ed648f6c557c8b3bbd95690434b28 /ext/tk/tkutil/tkutil.c
parentbd38e0c4f2a065ccf824ad41db0091e3290aa111 (diff)
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
Diffstat (limited to 'ext/tk/tkutil/tkutil.c')
-rw-r--r--ext/tk/tkutil/tkutil.c18
1 files changed, 3 insertions, 15 deletions
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);