diff options
author | Ben Toews <mastahyeti@gmail.com> | 2018-08-08 16:50:41 -0600 |
---|---|---|
committer | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2019-10-01 11:25:06 +1300 |
commit | c4515f5643adbd8c73ac6fddac4f0feca896d138 (patch) | |
tree | 9e285a1c3e0c5edeb49120dd24d000338345ab74 /ext/openssl/ossl_ts.c | |
parent | df14e2f0c13b2750b33181b36ead5681b72c336d (diff) | |
download | ruby-openssl-c4515f5643adbd8c73ac6fddac4f0feca896d138.tar.gz |
ts: fix another leak
Diffstat (limited to 'ext/openssl/ossl_ts.c')
-rwxr-xr-x | ext/openssl/ossl_ts.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/ext/openssl/ossl_ts.c b/ext/openssl/ossl_ts.c index deab1bb7..1d9acdf8 100755 --- a/ext/openssl/ossl_ts.c +++ b/ext/openssl/ossl_ts.c @@ -1039,6 +1039,7 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request) TS_RESP_CTX *ctx = NULL; BIO *req_bio; ASN1_INTEGER *asn1_serial = NULL; + ASN1_OBJECT *def_policy_id_obj = NULL; long lgen_time; const char * err_msg = NULL; int i, status = 0; @@ -1066,6 +1067,8 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request) err_msg = "No policy id in the request and no default policy set"; goto end; } + if (def_policy_id != Qnil && !TS_REQ_get_policy_id(req)) + def_policy_id_obj = obj_to_asn1obj(def_policy_id); if (!(ctx = TS_RESP_CTX_new())) { err_msg = "Memory allocation failed."; @@ -1090,11 +1093,8 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request) } TS_RESP_CTX_set_signer_key(ctx, sign_key); - if (def_policy_id != Qnil && !TS_REQ_get_policy_id(req)) { - ASN1_OBJECT *def_policy_id_obj = obj_to_asn1obj(def_policy_id); + if (def_policy_id != Qnil && !TS_REQ_get_policy_id(req)) TS_RESP_CTX_set_def_policy(ctx, def_policy_id_obj); - ASN1_OBJECT_free(def_policy_id_obj); - } if (TS_REQ_get_policy_id(req)) TS_RESP_CTX_set_def_policy(ctx, TS_REQ_get_policy_id(req)); TS_RESP_CTX_set_time_cb(ctx, ossl_tsfac_time_cb, &lgen_time); @@ -1121,6 +1121,7 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request) end: if(asn1_serial) ASN1_INTEGER_free(asn1_serial); + if(def_policy_id_obj) ASN1_OBJECT_free(def_policy_id_obj); if (ctx) TS_RESP_CTX_free(ctx); if (err_msg) { if (response) TS_RESP_free(response); |