From: Dr. Stephen Henson Date: Sat, 11 Feb 2012 23:12:34 +0000 (+0000) Subject: PR: 2703 X-Git-Tag: OpenSSL_0_9_8u~21 X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff_plain;h=6dcb6bf1c108ea46bede61f63276681bcb81d774 PR: 2703 Submitted by: Alexey Melnikov Fix some memory and resource leaks in CAPI ENGINE. --- diff --git a/engines/e_capi.c b/engines/e_capi.c index 5bd89c3a0e..9f38af3b22 100644 --- a/engines/e_capi.c +++ b/engines/e_capi.c @@ -1141,6 +1141,7 @@ static int capi_list_containers(CAPI_CTX *ctx, BIO *out) { CAPIerr(CAPI_F_CAPI_LIST_CONTAINERS, CAPI_R_ENUMCONTAINERS_ERROR); capi_addlasterror(); + CryptReleaseContext(hprov, 0); return 0; } CAPI_trace(ctx, "Got max container len %d\n", buflen); @@ -1558,6 +1559,8 @@ static int capi_ctx_set_provname(CAPI_CTX *ctx, LPSTR pname, DWORD type, int che } CryptReleaseContext(hprov, 0); } + if (ctx->cspname) + OPENSSL_free(ctx->cspname); ctx->cspname = BUF_strdup(pname); ctx->csptype = type; return 1; @@ -1567,9 +1570,12 @@ static int capi_ctx_set_provname_idx(CAPI_CTX *ctx, int idx) { LPSTR pname; DWORD type; + int res; if (capi_get_provname(ctx, &pname, &type, idx) != 1) return 0; - return capi_ctx_set_provname(ctx, pname, type, 0); + res = capi_ctx_set_provname(ctx, pname, type, 0); + OPENSSL_free(pname); + return res; } static int cert_issuer_match(STACK_OF(X509_NAME) *ca_dn, X509 *x)