summaryrefslogtreecommitdiffstats
path: root/encoding.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-16 11:43:12 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-16 11:43:12 +0000
commitff200fc0f11bafc373f8067f1546ebd2b5894344 (patch)
tree4e9589f7ba6772d8cbe0803ebedf11eee530dd7c /encoding.c
parentdacd6812f3e016e55268b9208eb73d8a768f954f (diff)
downloadruby-ff200fc0f11bafc373f8067f1546ebd2b5894344.tar.gz
ruby-ff200fc0f11bafc373f8067f1546ebd2b5894344.tar.xz
ruby-ff200fc0f11bafc373f8067f1546ebd2b5894344.zip
* encoding.c (rb_enc_compatible): check encoding incapable arguments.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/encoding.c b/encoding.c
index 335d1ae00..15a068728 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);
}