time64/ctime64_r: localtime64_r can fail
In ctime64_r, the call to localtime64_r can fail. If we don't check for
this and then call asctime64_r, the results are garbage.
Signed-off-by: Derrick Lyndon Pallas <derrick@pallas.us>
diff --git a/src/time64.c b/src/time64.c
index 8c08caf..2ed8562 100644
--- a/src/time64.c
+++ b/src/time64.c
@@ -806,7 +806,9 @@
char *ctime64_r( const Time64_T* time, char* result ) {
struct TM date;
- localtime64_r( time, &date );
+ if (!localtime64_r( time, &date ))
+ return NULL;
+
return asctime64_r( &date, result );
}