1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00

Realloc error handling memory leak fix.

This commit is contained in:
Ulrich Drepper
2001-12-29 15:57:15 +00:00
parent 9403ec5d23
commit d1dddedf78
10 changed files with 100 additions and 50 deletions

View File

@@ -74,12 +74,16 @@ _nl_init_era_entries (void)
}
else
{
struct era_entry *new_eras = eras;
if (num_eras != new_num_eras)
eras = (struct era_entry *) realloc (eras,
new_num_eras
* sizeof (struct era_entry));
if (eras == NULL)
new_eras =
(struct era_entry *) realloc (eras,
new_num_eras
* sizeof (struct era_entry));
if (new_eras == NULL)
{
free (eras);
num_eras = 0;
eras = NULL;
}
@@ -87,6 +91,7 @@ _nl_init_era_entries (void)
{
const char *ptr = _NL_CURRENT (LC_TIME, _NL_TIME_ERA_ENTRIES);
num_eras = new_num_eras;
eras = new_eras;
for (cnt = 0; cnt < num_eras; ++cnt)
{