summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-01-11 09:18:54 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-01-11 09:18:54 +0000
commit85e32dd2212bc6e5bb2b48c5b6c94e048e84afeb (patch)
tree09c1328183e4ac51711b93522b53b7f0c62d5b4d /re.c
parent5915dc245e5efac34d676ad29ebd38d6b46f16cf (diff)
* re.c (match_select): should propagate taintness.
* hash.c (rb_hash_set_default): Hash#default= should return the new value. * string.c (rb_str_to_i): accepts optional base argument. [new] * numeric.c (rb_fix2str): should not handle negative fixnum values int32 via calling sprintf() directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/re.c b/re.c
index 91d920bfdb..5e73ddbd8b 100644
--- a/re.c
+++ b/re.c
@@ -829,6 +829,7 @@ match_select(argc, argv, match)
VALUE result = rb_ary_new();
int i;
long idx;
+ int taint = OBJ_TAINTED(match);
for (i=0; i<argc; i++) {
idx = NUM2LONG(argv[i]);
@@ -837,8 +838,9 @@ match_select(argc, argv, match)
rb_ary_push(result, Qnil);
}
else {
- rb_ary_push(result, rb_str_new(ptr+regs->beg[idx],
- regs->end[idx]-regs->beg[idx]));
+ VALUE str = rb_str_new(ptr+regs->beg[i], regs->end[i]-regs->beg[i]);
+ if (taint) OBJ_TAINT(str);
+ rb_ary_push(result, str);
}
}
return result;
@@ -981,15 +983,11 @@ static VALUE
rb_reg_equal(re1, re2)
VALUE re1, re2;
{
- int min;
-
if (re1 == re2) return Qtrue;
if (TYPE(re2) != T_REGEXP) return Qfalse;
rb_reg_check(re1); rb_reg_check(re2);
if (RREGEXP(re1)->len != RREGEXP(re2)->len) return Qfalse;
- min = RREGEXP(re1)->len;
- if (min > RREGEXP(re2)->len) min = RREGEXP(re2)->len;
- if (memcmp(RREGEXP(re1)->str, RREGEXP(re2)->str, min) == 0 &&
+ if (memcmp(RREGEXP(re1)->str, RREGEXP(re2)->str, RREGEXP(re1)->len) == 0 &&
rb_reg_cur_kcode(re1) == rb_reg_cur_kcode(re2) &&
RREGEXP(re1)->ptr->options == RREGEXP(re2)->ptr->options) {
return Qtrue;