提交 5c10c33d 编写于 作者: R Rich Felker

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.
上级 1c86c7f5
...@@ -2,5 +2,7 @@ ...@@ -2,5 +2,7 @@
char *ctime(const time_t *t) char *ctime(const time_t *t)
{ {
return asctime(localtime(t)); struct tm *tm = localtime(t);
if (!tm) return 0;
return asctime(tm);
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册