projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
2d7d05f
)
handle errors from localtime_r in ctime_r
author
Rich Felker
<dalias@aerifal.cx>
Wed, 21 Jun 2017 00:31:35 +0000
(20:31 -0400)
committer
Rich Felker
<dalias@aerifal.cx>
Wed, 21 Jun 2017 00:31:35 +0000
(20:31 -0400)
POSIX requires ctime_r return a null pointer on failure, which can
occur if the input time_t value is not representable in broken down
form.
based on patch by Alexander Monakov.
src/time/ctime_r.c
patch
|
blob
|
history
diff --git
a/src/time/ctime_r.c
b/src/time/ctime_r.c
index d2260a165a2e88112f0c74e5f2d13628af09e2ff..3e24aa681beea2263d5350ba6c8f7473c09fe89e 100644
(file)
--- a/
src/time/ctime_r.c
+++ b/
src/time/ctime_r.c
@@
-2,7
+2,6
@@
char *ctime_r(const time_t *t, char *buf)
{
- struct tm tm;
- localtime_r(t, &tm);
- return asctime_r(&tm, buf);
+ struct tm tm, *tm_p = localtime_r(t, &tm);
+ return tm_p ? asctime_r(tm_p, buf) : 0;
}