mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
fd8b254705
commit
bc211f3634
3 changed files with 13 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Sat Jun 7 06:03:11 2014 Benoit Daloze <eregontp@gmail.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
Fri Jun 6 22:19:26 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Jun 6 22:19:26 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* compile.c (private_recv_p): check by node type, instead of a
|
* compile.c (private_recv_p): check by node type, instead of a
|
||||||
|
|
|
@ -370,9 +370,11 @@ rb_digest_instance_equal(VALUE self, VALUE other)
|
||||||
if (rb_obj_is_kind_of(other, rb_mDigest_Instance) == Qtrue) {
|
if (rb_obj_is_kind_of(other, rb_mDigest_Instance) == Qtrue) {
|
||||||
str1 = rb_digest_instance_digest(0, 0, self);
|
str1 = rb_digest_instance_digest(0, 0, self);
|
||||||
str2 = rb_digest_instance_digest(0, 0, other);
|
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);
|
str1 = rb_digest_instance_to_s(self);
|
||||||
str2 = other;
|
str2 = other;
|
||||||
|
} else {
|
||||||
|
return Qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* never blindly assume that subclass methods return strings */
|
/* never blindly assume that subclass methods return strings */
|
||||||
|
|
|
@ -69,6 +69,9 @@ module TestDigest
|
||||||
|
|
||||||
assert_equal(md1, md1.clone, self.class::ALGO)
|
assert_equal(md1, md1.clone, self.class::ALGO)
|
||||||
|
|
||||||
|
bug9913 = '[ruby-core:62967] [Bug #9913]'
|
||||||
|
assert_not_equal(md1, nil, bug9913)
|
||||||
|
|
||||||
md2 = self.class::ALGO.new
|
md2 = self.class::ALGO.new
|
||||||
md2 << "A"
|
md2 << "A"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue