diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-29 05:55:02 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-29 05:55:02 +0000 |
commit | 451fe269e5ab1270a53ac7bdeceabe47fd431f95 (patch) | |
tree | ed014c958a0f622db02af64186def2c70e4c00ba /ext/openssl/ossl_pkey_ec.c | |
parent | 5924f9a684ace630d3658a0d6e52270e3686ca9f (diff) | |
download | ruby-451fe269e5ab1270a53ac7bdeceabe47fd431f95.tar.gz |
openssl: wrapper object before alloc
* ext/openssl: make wrapper objects before allocating structs to
get rid of potential memory leaks.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl_pkey_ec.c')
-rw-r--r-- | ext/openssl/ossl_pkey_ec.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/openssl/ossl_pkey_ec.c b/ext/openssl/ossl_pkey_ec.c index d63f757394..c93e3cfb99 100644 --- a/ext/openssl/ossl_pkey_ec.c +++ b/ext/openssl/ossl_pkey_ec.c @@ -116,6 +116,7 @@ static VALUE ec_instance(VALUE klass, EC_KEY *ec) if (!ec) { return Qfalse; } + obj = NewPKey(klass); if (!(pkey = EVP_PKEY_new())) { return Qfalse; } @@ -123,7 +124,7 @@ static VALUE ec_instance(VALUE klass, EC_KEY *ec) EVP_PKEY_free(pkey); return Qfalse; } - WrapPKey(klass, obj, pkey); + SetPKey(obj, pkey); return obj; } @@ -135,10 +136,11 @@ VALUE ossl_ec_new(EVP_PKEY *pkey) if (!pkey) { obj = ec_instance(cEC, EC_KEY_new()); } else { + obj = NewPKey(cEC); if (EVP_PKEY_type(pkey->type) != EVP_PKEY_EC) { ossl_raise(rb_eTypeError, "Not a EC key!"); } - WrapPKey(cEC, obj, pkey); + SetPKey(obj, pkey); } if (obj == Qfalse) { ossl_raise(eECError, NULL); |