diff options
author | nobu <nobu@ruby-lang.org> | 2017-09-07 03:24:08 +0000 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2017-09-08 22:35:50 +0900 |
commit | d7984397f8fa6afc836175cc5ce1ca17ddeb630e (patch) | |
tree | 6e16c21e41180fbd7d4814a60eaa188d874a7c0f | |
parent | 8ed81ff4b0a893376f949c006942fea8f7fba8c3 (diff) | |
download | ruby-openssl-d7984397f8fa6afc836175cc5ce1ca17ddeb630e.tar.gz |
ruby.h: unnormalized Fixnum value
* include/ruby/ruby.h (ST2FIX): fix unnormalized Fixnum value bug
on mingw/mswin. [ruby-core:82687] [Bug #13877]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
[ky: add ST2FIX() definition to ext/openssl/ruby_missing.h, and adapt
the test case to the 2.0 branch.]
Sync-with-trunk: r59765
-rw-r--r-- | ext/openssl/ossl_bn.c | 2 | ||||
-rw-r--r-- | ext/openssl/ruby_missing.h | 10 | ||||
-rw-r--r-- | test/test_bn.rb | 1 |
3 files changed, 10 insertions, 3 deletions
diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c index aa0f2c60..29dc1a21 100644 --- a/ext/openssl/ossl_bn.c +++ b/ext/openssl/ossl_bn.c @@ -953,7 +953,7 @@ ossl_bn_hash(VALUE self) ossl_raise(eBNError, NULL); } - hash = INT2FIX(rb_memhash(buf, len)); + hash = ST2FIX(rb_memhash(buf, len)); xfree(buf); return hash; diff --git a/ext/openssl/ruby_missing.h b/ext/openssl/ruby_missing.h index 8dacc826..5b1481ae 100644 --- a/ext/openssl/ruby_missing.h +++ b/ext/openssl/ruby_missing.h @@ -15,9 +15,15 @@ #define FPTR_TO_FD(fptr) ((fptr)->fd) +/* Ruby 2.4 */ #ifndef RB_INTEGER_TYPE_P -/* for Ruby 2.3 compatibility */ -#define RB_INTEGER_TYPE_P(obj) (RB_FIXNUM_P(obj) || RB_TYPE_P(obj, T_BIGNUM)) +# define RB_INTEGER_TYPE_P(obj) (RB_FIXNUM_P(obj) || RB_TYPE_P(obj, T_BIGNUM)) +#endif + +/* Ruby 2.5 */ +#ifndef ST2FIX +# define RB_ST2FIX(h) LONG2FIX((long)(h)) +# define ST2FIX(h) RB_ST2FIX(h) #endif #endif /* _OSSL_RUBY_MISSING_H_ */ diff --git a/test/test_bn.rb b/test/test_bn.rb index 37ba5e55..5f3ae2b4 100644 --- a/test/test_bn.rb +++ b/test/test_bn.rb @@ -55,6 +55,7 @@ class OpenSSL::TestBN < OpenSSL::TestCase assert_equal(false, bn1.eql?(bn3)) assert_equal(bn1.hash, bn2.hash) assert_not_equal(bn3.hash, bn1.hash) + assert_instance_of(String, bn1.hash.to_s) end end |