aboutsummaryrefslogtreecommitdiff
path: root/src/timezone/localtime.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/timezone/localtime.c')
-rw-r--r--src/timezone/localtime.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/timezone/localtime.c b/src/timezone/localtime.c
index 31b06b037f4..a2260e590dd 100644
--- a/src/timezone/localtime.c
+++ b/src/timezone/localtime.c
@@ -1328,13 +1328,14 @@ gmtsub(pg_time_t const *timep, int32 offset, struct pg_tm *tmp)
struct pg_tm *result;
/* GMT timezone state data is kept here */
- static struct state gmtmem;
- static bool gmt_is_set = false;
-#define gmtptr (&gmtmem)
+ static struct state *gmtptr = NULL;
- if (!gmt_is_set)
+ if (gmtptr == NULL)
{
- gmt_is_set = true;
+ /* Allocate on first use */
+ gmtptr = (struct state *) malloc(sizeof(struct state));
+ if (gmtptr == NULL)
+ return NULL; /* errno should be set by malloc */
gmtload(gmtptr);
}
result = timesub(timep, offset, gmtptr, tmp);