From bc211f363443062b3218dd065218f93af10e44ff Mon Sep 17 00:00:00 2001 From: eregon Date: Fri, 6 Jun 2014 21:05:48 +0000 Subject: digest.c: fix #== for non-string arguments * ext/digest/digest.c (rb_digest_instance_equal): fix #== for non-string arguments. [ruby-core:62967] [Bug #9913] * test/digest/test_digest.rb: add test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/digest/digest.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ext/digest') diff --git a/ext/digest/digest.c b/ext/digest/digest.c index 527d0ed..8a53bd2 100644 --- a/ext/digest/digest.c +++ b/ext/digest/digest.c @@ -370,9 +370,11 @@ rb_digest_instance_equal(VALUE self, VALUE other) if (rb_obj_is_kind_of(other, rb_mDigest_Instance) == Qtrue) { str1 = rb_digest_instance_digest(0, 0, self); str2 = rb_digest_instance_digest(0, 0, other); - } else { + } else if (!NIL_P(rb_check_string_type(other))) { str1 = rb_digest_instance_to_s(self); str2 = other; + } else { + return Qfalse; } /* never blindly assume that subclass methods return strings */ -- cgit v1.1