aboutsummaryrefslogtreecommitdiff
path: root/contrib/tzcode
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/tzcode')
-rw-r--r--contrib/tzcode/localtime.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/contrib/tzcode/localtime.c b/contrib/tzcode/localtime.c
index 30ae18a965e8..1b52e26a5faf 100644
--- a/contrib/tzcode/localtime.c
+++ b/contrib/tzcode/localtime.c
@@ -1761,7 +1761,10 @@ localtime(const time_t *timep)
if ((p_tm = malloc(sizeof(*p_tm))) == NULL) {
return (NULL);
}
- _pthread_setspecific(localtime_key, p_tm);
+ if (_pthread_setspecific(localtime_key, p_tm) != 0) {
+ free(p_tm);
+ return (NULL);
+ }
}
}
return localtime_tzset(timep, p_tm, true);
@@ -1829,7 +1832,10 @@ gmtime(const time_t *timep)
if ((p_tm = malloc(sizeof(*p_tm))) == NULL) {
return (NULL);
}
- _pthread_setspecific(gmtime_key, p_tm);
+ if (_pthread_setspecific(gmtime_key, p_tm) != 0) {
+ free(p_tm);
+ return (NULL);
+ }
}
}
return gmtime_r(timep, p_tm);