summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Peters <fpeters@entrouvert.com>2006-11-21 17:52:31 +0000
committerFrederic Peters <fpeters@entrouvert.com>2006-11-21 17:52:31 +0000
commitbe247a65facaeea4485d5871297010b6911ab7d9 (patch)
treeda14758d140a537188d5c35f777f0412ff86956c
parentb45333444cc9c9a73718417861fd19e8602a1bae (diff)
fixed pkey memory leak
-rw-r--r--lasso/xml/tools.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/lasso/xml/tools.c b/lasso/xml/tools.c
index 48b72f1c..be3c1537 100644
--- a/lasso/xml/tools.c
+++ b/lasso/xml/tools.c
@@ -151,25 +151,19 @@ lasso_get_pem_file_type(const char *pem_file)
type = LASSO_PEM_FILE_TYPE_PUB_KEY;
EVP_PKEY_free(pkey);
} else {
- reset_success = BIO_reset(bio);
- if (reset_success == -1) {
- BIO_free(bio);
- return LASSO_PEM_FILE_TYPE_UNKNOWN;
- }
- pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL);
- if (pkey != NULL) {
- type = LASSO_PEM_FILE_TYPE_PRIVATE_KEY;
- EVP_PKEY_free(pkey);
- } else {
- reset_success = BIO_reset(bio);
- if (reset_success == -1) {
- BIO_free(bio);
- return LASSO_PEM_FILE_TYPE_UNKNOWN;
- }
- cert = PEM_read_bio_X509(bio, NULL, NULL, NULL);
- if (cert != NULL) {
- type = LASSO_PEM_FILE_TYPE_CERT;
- X509_free(cert);
+ if (BIO_reset(bio) == 0) {
+ pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL);
+ if (pkey != NULL) {
+ type = LASSO_PEM_FILE_TYPE_PRIVATE_KEY;
+ EVP_PKEY_free(pkey);
+ } else {
+ if (BIO_reset(bio) == 0) {
+ cert = PEM_read_bio_X509(bio, NULL, NULL, NULL);
+ if (cert != NULL) {
+ type = LASSO_PEM_FILE_TYPE_CERT;
+ X509_free(cert);
+ }
+ }
}
}
}