From: Bruno Haible Date: Sat, 30 Sep 2023 18:07:33 +0000 (+0200) Subject: intl: Merge from glibc. X-Git-Tag: v0.23~357 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d645c9ea3731d6d3b74387d64e12d2b6741c2c5;p=thirdparty%2Fgettext.git intl: Merge from glibc. Apply commit 2017-06-21 Florian Weimer _nl_load_domain: Use calloc instead of alloca --- diff --git a/gettext-runtime/intl/loadmsgcat.c b/gettext-runtime/intl/loadmsgcat.c index 999d92760..56ed15e99 100644 --- a/gettext-runtime/intl/loadmsgcat.c +++ b/gettext-runtime/intl/loadmsgcat.c @@ -32,29 +32,6 @@ #include #include -#ifdef __GNUC__ -# undef alloca -# define alloca __builtin_alloca -# define HAVE_ALLOCA 1 -#else -# ifdef _MSC_VER -# include -# define alloca _alloca -# else -# if defined HAVE_ALLOCA_H || defined _LIBC -# include -# else -# ifdef _AIX - #pragma alloca -# else -# ifndef alloca -char *alloca (); -# endif -# endif -# endif -# endif -#endif - #include #include @@ -395,15 +372,6 @@ char *alloca (); # define close _close #endif -/* For those losing systems which don't have `alloca' we have to add - some additional code emulating it. */ -#ifdef HAVE_ALLOCA -# define freea(p) /* nothing */ -#else -# define alloca(n) malloc (n) -# define freea(p) free (p) -#endif - /* For systems that distinguish between text and binary I/O. O_BINARY is usually declared in . */ #if !defined O_BINARY && defined _O_BINARY @@ -932,8 +900,9 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, ((char *) data + W (domain->must_swap, data->sysdep_segments_offset)); sysdep_segment_values = - (const char **) - alloca (n_sysdep_segments * sizeof (const char *)); + calloc (n_sysdep_segments, sizeof (const char *)); + if (sysdep_segment_values == NULL) + goto invalid; for (i = 0; i < n_sysdep_segments; i++) { const char *name = @@ -944,7 +913,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, if (!(namelen > 0 && name[namelen - 1] == '\0')) { - freea (sysdep_segment_values); + free (sysdep_segment_values); goto invalid; } @@ -1002,7 +971,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, if (sysdepref >= n_sysdep_segments) { /* Invalid. */ - freea (sysdep_segment_values); + free (sysdep_segment_values); goto invalid; } @@ -1219,7 +1188,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, domain->trans_sysdep_tab = NULL; } - freea (sysdep_segment_values); + free (sysdep_segment_values); } else {