From 8bcfa698a040698247ca20006a4aa4b6c1978c4b Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 16 Feb 2008 11:43:12 +0000 Subject: * 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 --- encoding.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'encoding.c') 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); } -- cgit v1.2.3