1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2014-10-30 06:33:11 +00:00
parent bd38e0c4f2
commit 40cc9231a9

View file

@ -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]);
}
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->full_subst_length += (subst_inf->keylen[chr] + 2);