mirror of
https://frontier.innolan.net/rainlance/amiga-tz.git
synced 2026-05-09 06:05:36 +00:00
Fix another 'localtime' initialization bug.
* localtime.c (tzload) [ALL_STATE]: Initialize sp->goback and sp->goahead even if memory allocation fails. (tzload, tzsetwall, tzset, gmtsub) [ALL_STATE]: Use malloc, not calloc, since the !ALL_STATE code has to work with reused storage anyway. * NEWS: Document Logan Chien's fix.
This commit is contained in:
5
NEWS
5
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.
|
||||
|
||||
18
localtime.c
18
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);
|
||||
|
||||
Reference in New Issue
Block a user