aboutsummaryrefslogtreecommitdiff
path: root/contrib/tzcode
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2023-01-13 14:57:19 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2023-01-14 17:16:30 +0000
commit96e68c393f65046c0cf69d29f89efcfee949e5de (patch)
treec28da594714c5f1fd14a5617cb92d5ee0cca99b4 /contrib/tzcode
parent3e2e5eebfaa0aebb2790bbde7f35d4c6c52e2596 (diff)
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);