aboutsummaryrefslogtreecommitdiff
path: root/locale/lc-time.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-12-29 15:57:15 +0000
committerUlrich Drepper <drepper@redhat.com>2001-12-29 15:57:15 +0000
commitd1dddedf7893fe70ed5d429485c8bcd0ab43f285 (patch)
tree99420c13234130854769150b8d81f5fe1d2528e3 /locale/lc-time.c
parent9403ec5d23e7dc209361b3dbae2fdc184e1684aa (diff)
downloadglibc-d1dddedf7893fe70ed5d429485c8bcd0ab43f285.zip
glibc-d1dddedf7893fe70ed5d429485c8bcd0ab43f285.tar.gz
glibc-d1dddedf7893fe70ed5d429485c8bcd0ab43f285.tar.bz2
Realloc error handling memory leak fix.
Diffstat (limited to 'locale/lc-time.c')
-rw-r--r--locale/lc-time.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/locale/lc-time.c b/locale/lc-time.c
index efa56b8..203a49b 100644
--- a/locale/lc-time.c
+++ b/locale/lc-time.c
@@ -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)
{