diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-28 06:44:43 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-28 06:44:43 +0000 |
commit | 5562ffe0c74444fdd2e48fa54d2c3b014b49fa77 (patch) | |
tree | 7cc8b23be4f9d9275b30e2c67453715fca40879f /ext/tk | |
parent | 93f2e52284c7f0ee435b474a6b28e79c614b5046 (diff) | |
download | ruby-5562ffe0c74444fdd2e48fa54d2c3b014b49fa77.tar.gz |
tkutil.c: check arguments type
* ext/tk/tkutil/tkutil.c (cbsubst_get_subst_key): check arguments
type. implicit conversion is disabled to get rid of method
calls which can modify other arguments.
* ext/tk/tkutil/tkutil.c (cbsubst_table_setup): ditto.
* ext/tk/tkutil/tkutil.c (cbsubst_scan_args): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50657 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk')
-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 7aecc5c591..6035a2a613 100644 --- a/ext/tk/tkutil/tkutil.c +++ b/ext/tk/tkutil/tkutil.c @@ -1455,7 +1455,6 @@ cbsubst_get_subst_key(self, str) struct cbsubst_info *inf; volatile VALUE list; volatile VALUE ret; - VALUE keyval; long i, len, keylen; int idx; char *buf, *ptr, *key; @@ -1469,8 +1468,8 @@ cbsubst_get_subst_key(self, str) ptr = buf = ALLOC_N(char, inf->full_subst_length + len + 1); for(i = 0; i < len; i++) { - keyval = RARRAY_PTR(list)[i]; - key = RSTRING_PTR(keyval); + VALUE keyval = RARRAY_CONST_PTR(list)[i]; + const char *key = (Check_Type(keyval, T_STRING), StringValueCStr(keyval)); if (*key == '%') { if (*(key + 2) == '\0') { /* single char */ @@ -1568,6 +1567,9 @@ cbsubst_table_setup(argc, argv, self) proc_inf = longkey_inf; longkey_inf = rb_ary_new(); } + Check_Type(key_inf, T_ARRAY); + Check_Type(longkey_inf, T_ARRAY); + Check_Type(proc_inf, T_ARRAY); /* check the number of longkeys */ if (RARRAY_LEN(longkey_inf) > 125 /* from 0x80 to 0xFD */) { @@ -1670,9 +1672,9 @@ cbsubst_scan_args(self, arg_key, val_ary) { struct cbsubst_info *inf; long idx; - unsigned char *keyptr = (unsigned char*)RSTRING_PTR(arg_key); + unsigned char *keyptr = (unsigned char*)StringValueCStr(arg_key); long keylen = RSTRING_LEN(arg_key); - long vallen = RARRAY_LEN(val_ary); + long vallen = (Check_Type(val_ary, T_ARRAY), RARRAY_LEN(val_ary)); unsigned char type_chr; volatile VALUE dst = rb_ary_new2(vallen); volatile VALUE proc; |