mirror of git://sourceware.org/git/glibc.git
_nl_load_domain: Use calloc instead of alloca
This commit is contained in:
parent
4dd8e7c0ce
commit
0a47d031e4
|
@ -1,3 +1,8 @@
|
||||||
|
2017-06-21 Florian Weimer <fweimer@redhat.com>
|
||||||
|
|
||||||
|
* intl/loadmsgcat.c: Remove alloca support.
|
||||||
|
(_nl_load_domain): Use calloc instead of alloca.
|
||||||
|
|
||||||
2017-04-21 Florian Weimer <fweimer@redhat.com>
|
2017-04-21 Florian Weimer <fweimer@redhat.com>
|
||||||
|
|
||||||
* malloc/Makefile (tests-internal): Add tst-alloc_buffer.
|
* malloc/Makefile (tests-internal): Add tst-alloc_buffer.
|
||||||
|
|
|
@ -32,29 +32,6 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
# undef alloca
|
|
||||||
# define alloca __builtin_alloca
|
|
||||||
# define HAVE_ALLOCA 1
|
|
||||||
#else
|
|
||||||
# ifdef _MSC_VER
|
|
||||||
# include <malloc.h>
|
|
||||||
# define alloca _alloca
|
|
||||||
# else
|
|
||||||
# if defined HAVE_ALLOCA_H || defined _LIBC
|
|
||||||
# include <alloca.h>
|
|
||||||
# else
|
|
||||||
# ifdef _AIX
|
|
||||||
#pragma alloca
|
|
||||||
# else
|
|
||||||
# ifndef alloca
|
|
||||||
char *alloca ();
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -476,15 +453,6 @@ char *alloca ();
|
||||||
# define munmap(addr, len) __munmap (addr, len)
|
# define munmap(addr, len) __munmap (addr, len)
|
||||||
#endif
|
#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.
|
/* For systems that distinguish between text and binary I/O.
|
||||||
O_BINARY is usually declared in <fcntl.h>. */
|
O_BINARY is usually declared in <fcntl.h>. */
|
||||||
#if !defined O_BINARY && defined _O_BINARY
|
#if !defined O_BINARY && defined _O_BINARY
|
||||||
|
@ -982,9 +950,10 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
|
||||||
sysdep_segments = (const struct sysdep_segment *)
|
sysdep_segments = (const struct sysdep_segment *)
|
||||||
((char *) data
|
((char *) data
|
||||||
+ W (domain->must_swap, data->sysdep_segments_offset));
|
+ W (domain->must_swap, data->sysdep_segments_offset));
|
||||||
sysdep_segment_values =
|
sysdep_segment_values = calloc
|
||||||
(const char **)
|
(n_sysdep_segments, sizeof (const char *));
|
||||||
alloca (n_sysdep_segments * sizeof (const char *));
|
if (sysdep_segment_values == NULL)
|
||||||
|
goto invalid;
|
||||||
for (i = 0; i < n_sysdep_segments; i++)
|
for (i = 0; i < n_sysdep_segments; i++)
|
||||||
{
|
{
|
||||||
const char *name =
|
const char *name =
|
||||||
|
@ -995,7 +964,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
|
||||||
|
|
||||||
if (!(namelen > 0 && name[namelen - 1] == '\0'))
|
if (!(namelen > 0 && name[namelen - 1] == '\0'))
|
||||||
{
|
{
|
||||||
freea (sysdep_segment_values);
|
free (sysdep_segment_values);
|
||||||
goto invalid;
|
goto invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1046,7 +1015,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
|
||||||
if (sysdepref >= n_sysdep_segments)
|
if (sysdepref >= n_sysdep_segments)
|
||||||
{
|
{
|
||||||
/* Invalid. */
|
/* Invalid. */
|
||||||
freea (sysdep_segment_values);
|
free (sysdep_segment_values);
|
||||||
goto invalid;
|
goto invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1250,7 +1219,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
|
||||||
domain->trans_sysdep_tab = NULL;
|
domain->trans_sysdep_tab = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
freea (sysdep_segment_values);
|
free (sysdep_segment_values);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue