diff options
-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 |