mirror of
https://git.musl-libc.org/git/musl
synced 2025-02-09 14:54:30 +03:00
handle localtime errors in ctime
ctime passes the result from localtime directly to asctime. But in case of error, localtime returns 0. This causes an error (NULL pointer dereference) in asctime. based on patch by Omer Anson.
This commit is contained in:
parent
1c86c7f5c2
commit
5c10c33d2a
@ -2,5 +2,7 @@
|
||||
|
||||
char *ctime(const time_t *t)
|
||||
{
|
||||
return asctime(localtime(t));
|
||||
struct tm *tm = localtime(t);
|
||||
if (!tm) return 0;
|
||||
return asctime(tm);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user