From d6f07e3af3893ab2a8ad72a141b0b3e667df493e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 15 May 2013 10:37:10 +0200 Subject: Use counter when freeing cred_store configuration. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Günther Deschner Reviewed-by: Simo Sorce --- proxy/src/gp_config.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/proxy/src/gp_config.c b/proxy/src/gp_config.c index a906128..8be669a 100644 --- a/proxy/src/gp_config.c +++ b/proxy/src/gp_config.c @@ -31,7 +31,7 @@ #include "gp_proxy.h" #include "gp_config.h" -static void free_str_array(const char ***a) +static void free_str_array(const char ***a, int *count) { const char **array = *a; int i; @@ -39,8 +39,14 @@ static void free_str_array(const char ***a) if (!a) { return; } - for (i = 0; array[i]; i++) { - safefree(array[i]); + if (count) { + for (i = 0; i < *count; i++) { + safefree(array[i]); + } + } else { + for (i = 0; array[i]; i++) { + safefree(array[i]); + } } safefree(*a); } @@ -50,7 +56,8 @@ static void gp_service_free(struct gp_service *svc) free(svc->name); if (svc->mechs & GP_CRED_KRB5) { free(svc->krb5.principal); - free_str_array(&(svc->krb5.cred_store)); + free_str_array(&(svc->krb5.cred_store), + &svc->krb5.cred_count); } gp_free_creds_handle(&svc->creds_handle); memset(svc, 0, sizeof(struct gp_service)); -- cgit