From: Rich Felker Date: Thu, 15 Jun 2017 16:58:08 +0000 (-0400) Subject: handle localtime errors in ctime X-Git-Tag: v1.1.17~56 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5c10c33d2a35204ee76931625a007fcc8cca3228;p=oweals%2Fmusl.git 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. --- diff --git a/src/time/ctime.c b/src/time/ctime.c index 185ec554..36029315 100644 --- a/src/time/ctime.c +++ b/src/time/ctime.c @@ -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); }