diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-03 18:28:56 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-03 18:28:56 +0000 |
commit | 7b58445ebd3218011c1cebdc0e6693cb008bb006 (patch) | |
tree | b56582551c4b90d34ffc517f085ec11c46b48d87 /ext/openssl/ossl_bn.c | |
parent | 7181490def5ad5670e2503e91c526eab1039b008 (diff) | |
download | ruby-7b58445ebd3218011c1cebdc0e6693cb008bb006.tar.gz |
* ext/openssl/ossl_bn.c (ossl_bn_initialize): fix can't create from bn.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl_bn.c')
-rw-r--r-- | ext/openssl/ossl_bn.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c index 5d690af52d..822b854efe 100644 --- a/ext/openssl/ossl_bn.c +++ b/ext/openssl/ossl_bn.c @@ -119,11 +119,11 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self) if (rb_scan_args(argc, argv, "11", &str, &bs) == 2) { base = NUM2INT(bs); } - StringValue(str); - GetBN(self, bn); + if (RTEST(rb_obj_is_kind_of(str, cBN))) { BIGNUM *other; + GetBN(self, bn); GetBN(str, other); /* Safe - we checked kind_of? above */ if (!BN_copy(bn, other)) { ossl_raise(eBNError, NULL); @@ -131,6 +131,8 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self) return self; } + StringValue(str); + GetBN(self, bn); switch (base) { case 0: if (!BN_mpi2bn((unsigned char *)RSTRING_PTR(str), RSTRING_LENINT(str), bn)) { |