diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-12-04 21:22:35 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-12-04 21:22:35 +0900 |
commit | 182604c8c35a7ae7bbf097f7d8b8d2eacc817f2c (patch) | |
tree | 8e07edc4dd662b481bb6c548eee7b1f78f5bccdb /ext/openssl/ossl_bn.h | |
parent | 72126d6c8b88abd69c3565fc3bbbd5ed1e401611 (diff) | |
download | ruby-openssl-182604c8c35a7ae7bbf097f7d8b8d2eacc817f2c.tar.gz |
bn: keep reference to temporary OpenSSL::BN object created by GetBNPtr()
GetBNPtr() accepts both OpenSSL::BN and Ruby integers. In the latter
case, it creates a temporary OpenSSL::BN internally. The OpenSSL::BN
object immediately disappears from the stack and is not protected from
GC.
Fixes: https://github.com/ruby/openssl/issues/87
Diffstat (limited to 'ext/openssl/ossl_bn.h')
-rw-r--r-- | ext/openssl/ossl_bn.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ext/openssl/ossl_bn.h b/ext/openssl/ossl_bn.h index 4cd9d060..a19ba194 100644 --- a/ext/openssl/ossl_bn.h +++ b/ext/openssl/ossl_bn.h @@ -15,8 +15,10 @@ extern VALUE eBNError; extern BN_CTX *ossl_bn_ctx; +#define GetBNPtr(obj) ossl_bn_value_ptr(&(obj)) + VALUE ossl_bn_new(const BIGNUM *); -BIGNUM *GetBNPtr(VALUE); +BIGNUM *ossl_bn_value_ptr(volatile VALUE *); void Init_ossl_bn(void); |