diff --git a/NEWS b/NEWS index 3d3a922..4d4f244 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,11 @@ News for the tz database Unreleased, experimental changes + Changes affecting code + + A uninitialized-storage bug in 'localtime' has been fixed. + (Thanks to Logan Chien.) + Changes affecting commentary The boundary of the US Pacific time zone is given more accurately. diff --git a/localtime.c b/localtime.c index 5ee2f3b..57d7d83 100644 --- a/localtime.c +++ b/localtime.c @@ -339,17 +339,19 @@ tzload(register const char *name, register struct state *const sp, 4 * TZ_MAX_TIMES]; } u_t; #ifdef ALL_STATE - register u_t * up; - - up = (u_t *) calloc(1, sizeof *up); - if (up == NULL) - return -1; + register u_t * const up = malloc(sizeof *up); #else /* !defined ALL_STATE */ u_t u; register u_t * const up = &u; #endif /* !defined ALL_STATE */ sp->goback = sp->goahead = FALSE; + +#ifdef ALL_STATE + if (up == NULL) + return -1; +#endif + if (name == NULL && (name = TZDEFAULT) == NULL) goto oops; { @@ -1190,7 +1192,7 @@ tzsetwall(void) #ifdef ALL_STATE if (lclptr == NULL) { - lclptr = calloc(1, sizeof *lclptr); + lclptr = malloc(sizeof *lclptr); if (lclptr == NULL) { settzname(); /* all we can do */ return; @@ -1221,7 +1223,7 @@ tzset(void) #ifdef ALL_STATE if (lclptr == NULL) { - lclptr = calloc(1, sizeof *lclptr); + lclptr = malloc(sizeof *lclptr); if (lclptr == NULL) { settzname(); /* all we can do */ return; @@ -1363,7 +1365,7 @@ gmtsub(const time_t *const timep, const int_fast32_t offset, if (!gmt_is_set) { gmt_is_set = TRUE; #ifdef ALL_STATE - gmtptr = calloc(1, sizeof *gmtptr); + gmtptr = malloc(sizeof *gmtptr); if (gmtptr != NULL) #endif /* defined ALL_STATE */ gmtload(gmtptr);