From c5f1c9e222864fc1858d48463802bb383d1ff1aa Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 13 Apr 2019 07:33:10 +0000 Subject: merge revision(s) 67497,67498: [Backport #15760] ext/openssl/ossl_bn.c (ossl_bn_initialize): get rid of SEGV OpenSSL::BN.new(nil, 2) dumped core. [ruby-core:92231] [Bug #15760] * expand tabs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/openssl/ossl_bn.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'ext') diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c index 4666ce6c2f..6f0064e966 100644 --- a/ext/openssl/ossl_bn.c +++ b/ext/openssl/ossl_bn.c @@ -187,6 +187,7 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self) BIGNUM *bn; VALUE str, bs; int base = 10; + char *ptr; if (rb_scan_args(argc, argv, "11", &str, &bs) == 2) { base = NUM2INT(bs); @@ -213,12 +214,14 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self) GetBN(self, bn); switch (base) { case 0: - if (!BN_mpi2bn((unsigned char *)StringValuePtr(str), RSTRING_LENINT(str), bn)) { + ptr = StringValuePtr(str); + if (!BN_mpi2bn((unsigned char *)ptr, RSTRING_LENINT(str), bn)) { ossl_raise(eBNError, NULL); } break; case 2: - if (!BN_bin2bn((unsigned char *)StringValuePtr(str), RSTRING_LENINT(str), bn)) { + ptr = StringValuePtr(str); + if (!BN_bin2bn((unsigned char *)ptr, RSTRING_LENINT(str), bn)) { ossl_raise(eBNError, NULL); } break; -- cgit v1.2.3