From 23ee89acacaf7f06517c82f31ad9f3a958b0324c Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Tue, 3 Jan 2017 16:10:07 +0100 Subject: gnutls_x509_ext_import_policies: fixed memory leak on error path Signed-off-by: Nikos Mavrogiannopoulos --- lib/x509/x509_ext.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/x509/x509_ext.c b/lib/x509/x509_ext.c index 2cbb684691..b947b46028 100644 --- a/lib/x509/x509_ext.c +++ b/lib/x509/x509_ext.c @@ -1706,8 +1706,9 @@ void gnutls_x509_policies_deinit(gnutls_x509_policies_t policies) { unsigned i; - for (i = 0; i < policies->size; i++) + for (i = 0; i < policies->size; i++) { gnutls_x509_policy_release(&policies->policy[i]); + } gnutls_free(policies); } @@ -1846,7 +1847,7 @@ int gnutls_x509_ext_import_policies(const gnutls_datum_t * ext, /* create a string like "?1" */ snprintf(tmpstr, sizeof(tmpstr), "?%u.policyIdentifier", j + 1); - current = j; + current = j+1; ret = _gnutls_x509_read_value(c2, tmpstr, &tmpd); if (ret == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND) @@ -1876,7 +1877,7 @@ int gnutls_x509_ext_import_policies(const gnutls_datum_t * ext, if (ret != ASN1_SUCCESS) { gnutls_assert(); ret = _gnutls_asn2err(ret); - goto cleanup; + goto full_cleanup; } if (strcmp(tmpoid, "1.3.6.1.5.5.7.2.1") == 0) { -- cgit v1.2.1