diff options
author | Ishan SinghLevett <Ishan.SinghLevett@baesystemsdetica.com> | 2013-10-15 20:48:22 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2013-10-15 20:48:22 +0200 |
commit | 18ca0aa9842d3fb6e0740515df7b5960fab4408e (patch) | |
tree | face79298b1ffbd7bf64be585fdedbefae1080bb | |
parent | c4e6c33b13ba2968713a468736948b6364a50810 (diff) |
usercertinmem: fix memory leaks
-rw-r--r-- | docs/examples/usercertinmem.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/docs/examples/usercertinmem.c b/docs/examples/usercertinmem.c index 99740fdce..36c1c9064 100644 --- a/docs/examples/usercertinmem.c +++ b/docs/examples/usercertinmem.c @@ -22,8 +22,9 @@ /* Example using an in memory PEM user certificate and RSA key to retrieve an * https page. * Written by Ishan SinghLevett, based on Theo Borm's cacertinmem.c. - * Note this example does not use a CA certificate, however one should be used - * if you want a properly secure connection + * Note that to maintain simplicity this example does not use a CA certificate + * for peer verification. However, some form of peer verification + * must be used in real circumstances when a secure connection is required. */ #include <openssl/ssl.h> @@ -152,6 +153,18 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm) printf("Use Key failed\n"); } + /* free resources that have been allocated by openssl functions */ + if (bio) + BIO_free(bio); + + if (kbio) + BIO_free(kbio); + + if (rsa) + RSA_free(rsa); + + if (cert) + X509_free(cert); /* all set to go */ return CURLE_OK ; |