From 8bcfa698a040698247ca20006a4aa4b6c1978c4b Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 16 Feb 2008 11:43:12 +0000 Subject: [PATCH] * encoding.c (rb_enc_compatible): check encoding incapable arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 +++++++--- encoding.c | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c609c0d145..35a49c22ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Feb 16 18:13:53 2008 Tanaka Akira + + * encoding.c (rb_enc_compatible): check encoding incapable arguments. + Sat Feb 16 20:12:47 2008 Tanaka Akira * re.c (match_inspect): avoid SEGV with MatchData.allocate.inspect. @@ -108,7 +112,7 @@ Fri Feb 15 15:23:12 2008 Nobuyoshi Nakada Fri Feb 15 10:35:54 2008 Nobuyoshi Nakada - * re.c (rb_reg_quote): set US-ACII for ASCII-only string. + * re.c (rb_reg_quote): set US-ASCII for ASCII-only string. [ruby-dev:33785] Fri Feb 15 10:27:47 2008 Nobuyoshi Nakada @@ -275,7 +279,7 @@ Tue Feb 12 15:27:19 2008 NARUSE, Yui * bootstraptest/runner.rb, bootstraptest/test_method.rb, enc/depend, instruby.rb, lib/mkmf.rb, lib/test/unit/util/procwrapper.rb, mkconfig.rb, sample/test.rb, template/vm.inc.tmpl, - test/ruby/test_stringchar.rb: fixes arround String#gsub. + test/ruby/test_stringchar.rb: fixes around String#gsub. Tue Feb 12 15:11:47 2008 NARUSE, Yui @@ -290,7 +294,7 @@ Tue Feb 12 15:11:47 2008 NARUSE, Yui lib/rexml/quickpath.rb, lib/rexml/text.rb, lib/rss/parser.rb, lib/uri/common.rb, lib/uri/generic.rb, lib/webrick/httpresponse.rb, lib/webrick/httpservlet/filehandler.rb, lib/yaml/baseemitter.rb, - lib/yaml/encoding.rb: performance tuning arround String#gsub. + lib/yaml/encoding.rb: performance tuning around String#gsub. Tue Feb 12 12:16:45 2008 Yukihiro Matsumoto diff --git a/encoding.c b/encoding.c index 335d1ae00c..15a0687281 100644 --- a/encoding.c +++ b/encoding.c @@ -659,6 +659,9 @@ rb_enc_compatible(VALUE str1, VALUE str2) idx1 = rb_enc_get_index(str1); idx2 = rb_enc_get_index(str2); + if (idx1 < 0 || idx2 < 0) + return 0; + if (idx1 == idx2) { return rb_enc_from_index(idx1); }