Project

General

Profile

Bug #9913

Digest == throws TypeError when testing against nil

Added by Malakai97 (Bryan Hockey) almost 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
[ruby-core:62967]

Description

Also present in ruby -v: jruby 1.7.10 (1.9.3p392) 2014-01-09 c4ecd6b on OpenJDK 64-Bit Server VM 1.7.0_55-b14 [linux-amd64]

To recreate:

require 'digest'
x = Digest::SHA256.new()
x == nil
TypeError: can't convert nil into String

Workaround:
w1: use #nil?
w2: reverse rhs, lhs, e.g. if nil == some_digest

Associated revisions

Revision bc211f36
Added by Eregon (Benoit Daloze) almost 4 years ago

digest.c: fix #== for non-string arguments

  • ext/digest/digest.c (rb_digest_instance_equal): fix #== for non-string arguments. [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

Revision 46368
Added by Eregon (Benoit Daloze) almost 4 years ago

digest.c: fix #== for non-string arguments

  • ext/digest/digest.c (rb_digest_instance_equal): fix #== for non-string arguments. [Bug #9913]
  • test/digest/test_digest.rb: add test for above.

Revision 46368
Added by Eregon (Benoit Daloze) almost 4 years ago

digest.c: fix #== for non-string arguments

  • ext/digest/digest.c (rb_digest_instance_equal): fix #== for non-string arguments. [Bug #9913]
  • test/digest/test_digest.rb: add test for above.

Revision 46368
Added by Eregon (Benoit Daloze) almost 4 years ago

digest.c: fix #== for non-string arguments

  • ext/digest/digest.c (rb_digest_instance_equal): fix #== for non-string arguments. [Bug #9913]
  • test/digest/test_digest.rb: add test for above.

Revision 46368
Added by Eregon (Benoit Daloze) almost 4 years ago

digest.c: fix #== for non-string arguments

  • ext/digest/digest.c (rb_digest_instance_equal): fix #== for non-string arguments. [Bug #9913]
  • test/digest/test_digest.rb: add test for above.

Revision 46368
Added by Eregon (Benoit Daloze) almost 4 years ago

digest.c: fix #== for non-string arguments

  • ext/digest/digest.c (rb_digest_instance_equal): fix #== for non-string arguments. [Bug #9913]
  • test/digest/test_digest.rb: add test for above.

Revision 63517876
Added by nobu (Nobuyoshi Nakada) almost 4 years ago

digest.c: call to_s once

  • ext/digest/digest.c (rb_digest_instance_equal): no need to call to_s twice. [Bug #9913]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 46371
Added by nobu (Nobuyoshi Nakada) almost 4 years ago

digest.c: call to_s once

  • ext/digest/digest.c (rb_digest_instance_equal): no need to call to_s twice. [Bug #9913]

Revision 46371
Added by nobu (Nobuyoshi Nakada) almost 4 years ago

digest.c: call to_s once

  • ext/digest/digest.c (rb_digest_instance_equal): no need to call to_s twice. [Bug #9913]

Revision 46371
Added by nobu (Nobuyoshi Nakada) almost 4 years ago

digest.c: call to_s once

  • ext/digest/digest.c (rb_digest_instance_equal): no need to call to_s twice. [Bug #9913]

Revision 46371
Added by nobu (Nobuyoshi Nakada) almost 4 years ago

digest.c: call to_s once

  • ext/digest/digest.c (rb_digest_instance_equal): no need to call to_s twice. [Bug #9913]

Revision 46371
Added by nobu (Nobuyoshi Nakada) almost 4 years ago

digest.c: call to_s once

  • ext/digest/digest.c (rb_digest_instance_equal): no need to call to_s twice. [Bug #9913]

Revision 9bc1b8e9
Added by nagachika (Tomoyuki Chikanaga) almost 4 years ago

merge revision(s) r46368,r46371: [Backport #9913]

* ext/digest/digest.c (rb_digest_instance_equal):
  fix #== for non-string arguments.  [Bug #9913]

* test/digest/test_digest.rb: add test for above.

* ext/digest/digest.c (rb_digest_instance_equal): no need to call
  `to_s` twice.  [Bug #9913]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 46809
Added by nagachika (Tomoyuki Chikanaga) almost 4 years ago

merge revision(s) r46368,r46371: [Backport #9913]

* ext/digest/digest.c (rb_digest_instance_equal):
  fix #== for non-string arguments.  [Bug #9913]

* test/digest/test_digest.rb: add test for above.

* ext/digest/digest.c (rb_digest_instance_equal): no need to call
  `to_s` twice.  [Bug #9913]

Revision a102b685
Added by usa (Usaku NAKAMURA) over 3 years ago

merge revision(s) 46368,46371: [Backport #9913]

* ext/digest/digest.c (rb_digest_instance_equal):
  fix #== for non-string arguments.  [Bug #9913]

* test/digest/test_digest.rb: add test for above.

* ext/digest/digest.c (rb_digest_instance_equal): no need to call
  `to_s` twice.  [Bug #9913]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@47333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 47333
Added by usa (Usaku NAKAMURA) over 3 years ago

merge revision(s) 46368,46371: [Backport #9913]

* ext/digest/digest.c (rb_digest_instance_equal):
  fix #== for non-string arguments.  [Bug #9913]

* test/digest/test_digest.rb: add test for above.

* ext/digest/digest.c (rb_digest_instance_equal): no need to call
  `to_s` twice.  [Bug #9913]

History

#1 [ruby-core:62969] Updated by Eregon (Benoit Daloze) almost 4 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Applied in changeset r46368.


digest.c: fix #== for non-string arguments

  • ext/digest/digest.c (rb_digest_instance_equal): fix #== for non-string arguments. [Bug #9913]
  • test/digest/test_digest.rb: add test for above.

#2 [ruby-core:63562] Updated by nagachika (Tomoyuki Chikanaga) almost 4 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: REQUIRED, 2.1: REQUIRED

#3 [ruby-core:63691] Updated by nagachika (Tomoyuki Chikanaga) almost 4 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED to 2.0.0: REQUIRED, 2.1: DONE

Backported into ruby_2_1 branch at r46809.

#4 [ruby-core:64687] Updated by usa (Usaku NAKAMURA) over 3 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: DONE to 2.0.0: DONE, 2.1: DONE

backported into ruby_2_0_0 at r47333.

Also available in: Atom PDF