From: Bruno Haible Date: Mon, 15 Jul 2002 12:40:17 +0000 (+0000) Subject: Fix memory leaks when there is no alloca(). X-Git-Tag: v0.11.3~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c585c6afdc560dc364e51c5e49644714ae6f729e;p=thirdparty%2Fgettext.git Fix memory leaks when there is no alloca(). --- diff --git a/intl/ChangeLog b/intl/ChangeLog index 0a39222a5..9ea3f048d 100644 --- a/intl/ChangeLog +++ b/intl/ChangeLog @@ -1,3 +1,10 @@ +2002-07-13 Bruno Haible + + * dcigettext.c (freea): New macro. + (FREE_BLOCKS): Free also the registered blocks. + (DCIGETTEXT): Free the 'search' variable. + Reported by Andreas Fischer . + 2002-06-13 Bruno Haible Make absolute pathnames inside $LANGUAGE work. diff --git a/intl/dcigettext.c b/intl/dcigettext.c index b5bf3fb5d..bec5dd33e 100644 --- a/intl/dcigettext.c +++ b/intl/dcigettext.c @@ -306,6 +306,7 @@ static const char *guess_category_value PARAMS ((int category, some additional code emulating it. */ #ifdef HAVE_ALLOCA /* Nothing has to be done. */ +# define freea(p) /* nothing */ # define ADD_BLOCK(list, address) /* nothing */ # define FREE_BLOCKS(list) /* nothing */ #else @@ -330,11 +331,13 @@ struct block_list while (list != NULL) { \ struct block_list *old = list; \ list = list->next; \ + free (old->address); \ free (old); \ } \ } while (0) # undef alloca # define alloca(size) (malloc (size)) +# define freea(p) free (p) #endif /* have alloca */ @@ -460,6 +463,7 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) search->category = category; foundp = (struct known_translation_t **) tfind (search, &root, transcmp); + freea (search); if (foundp != NULL && (*foundp)->counter == _nl_msg_cat_cntr) { /* Now deal with plural. */