From: Daiki Ueno Date: Thu, 10 Sep 2015 07:38:51 +0000 (+0900) Subject: xlocator, its: Fix memory leaks X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac4f445d652ba3d1f38ecd606903f26291847b69;p=thirdparty%2Fgettext.git xlocator, its: Fix memory leaks --- diff --git a/gettext-tools/src/its.c b/gettext-tools/src/its.c index c884e5829..a97631046 100644 --- a/gettext-tools/src/its.c +++ b/gettext-tools/src/its.c @@ -754,6 +754,7 @@ its_rule_list_add_file (struct its_rule_list_ty *rules, rules->items[rules->nitems++] = rule; } + xmlFreeDoc (doc); return true; } diff --git a/gettext-tools/src/xlocator.c b/gettext-tools/src/xlocator.c index 5844b3b50..664f040d2 100644 --- a/gettext-tools/src/xlocator.c +++ b/gettext-tools/src/xlocator.c @@ -166,11 +166,11 @@ static char * xlocator_list_resolve_target (struct xlocator_list_ty *locators, struct xlocator_target_ty *target) { - const char *target_uri = NULL; + char *target_uri = NULL; char *result = NULL; if (!target->is_indirection) - target_uri = target->uri; + target_uri = xstrdup (target->uri); else { void *value; @@ -201,11 +201,14 @@ xlocator_list_resolve_target (struct xlocator_list_ty *locators, free (path); uri = xmlParseURI ((const char *) absolute_uri); + xmlFree (absolute_uri); + if (uri != NULL) result = xstrdup (uri->path); xmlFreeURI (uri); } + free (target_uri); return result; } @@ -416,6 +419,7 @@ xlocator_list_add_file (struct xlocator_list_ty *locators, } } + xmlFreeDoc (doc); return true; } @@ -506,9 +510,26 @@ xlocator_destroy (struct xlocator_ty *locator) void xlocator_list_destroy (struct xlocator_list_ty *locators) { + void *iter; + const void *key; + size_t keylen; + void *data; + + iter = NULL; + while (hash_iterate (&locators->indirections, &iter, &key, &keylen, &data) + == 0) + { + struct xlocator_target_ty *target = data; + free (target->uri); + free (target); + } hash_destroy (&locators->indirections); + + free (locators->base); + while (locators->nitems-- > 0) xlocator_destroy (&locators->items[locators->nitems]); + free (locators->items); } void