aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_pkcs12.c
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-08-03 21:35:29 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-08-16 14:22:07 +0900
commitdc1efe5cdd47a1a590438ba1eced114e05468834 (patch)
tree06cb1fd2ab511c83642092eb639f1abc7a1c6b72 /ext/openssl/ossl_pkcs12.c
parentc63e0ed3d76c66758dd6ffeb97ff38414082b65c (diff)
downloadruby-openssl-dc1efe5cdd47a1a590438ba1eced114e05468834.tar.gz
pkcs12: fix memory leak in PKCS12.create
ossl_*_ary2sk() function must be called after any other functions that may raise.
Diffstat (limited to 'ext/openssl/ossl_pkcs12.c')
-rw-r--r--ext/openssl/ossl_pkcs12.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ext/openssl/ossl_pkcs12.c b/ext/openssl/ossl_pkcs12.c
index 33ad08a7..a7daad20 100644
--- a/ext/openssl/ossl_pkcs12.c
+++ b/ext/openssl/ossl_pkcs12.c
@@ -123,7 +123,6 @@ ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self)
friendlyname = NIL_P(name) ? NULL : StringValueCStr(name);
key = GetPKeyPtr(pkey);
x509 = GetX509CertPtr(cert);
- x509s = NIL_P(ca) ? NULL : ossl_x509_ary2sk(ca);
/* TODO: make a VALUE to nid function */
if (!NIL_P(key_nid)) {
if ((nkey = OBJ_txt2nid(StringValueCStr(key_nid))) == NID_undef)
@@ -141,6 +140,7 @@ ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self)
ktype = NUM2INT(keytype);
obj = NewPKCS12(cPKCS12);
+ x509s = NIL_P(ca) ? NULL : ossl_x509_ary2sk(ca);
p12 = PKCS12_create(passphrase, friendlyname, key, x509, x509s,
nkey, ncert, kiter, miter, ktype);
sk_X509_pop_free(x509s, X509_free);