summaryrefslogtreecommitdiff
path: root/otherlibs/unix/gmtime.c
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/unix/gmtime.c')
-rw-r--r--otherlibs/unix/gmtime.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/otherlibs/unix/gmtime.c b/otherlibs/unix/gmtime.c
index 0ecf8b99b3..b7c8b28a24 100644
--- a/otherlibs/unix/gmtime.c
+++ b/otherlibs/unix/gmtime.c
@@ -16,6 +16,7 @@
#include <memory.h>
#include "unixsupport.h"
#include <time.h>
+#include <errno.h>
static value alloc_tm(struct tm *tm)
{
@@ -36,15 +37,21 @@ static value alloc_tm(struct tm *tm)
value unix_gmtime(value t) /* ML */
{
time_t clock;
+ struct tm * tm;
clock = (time_t) Double_val(t);
- return alloc_tm(gmtime(&clock));
+ tm = gmtime(&clock);
+ if (tm == NULL) unix_error(EINVAL, "gmtime", Nothing);
+ return alloc_tm(tm);
}
value unix_localtime(value t) /* ML */
{
time_t clock;
+ struct tm * tm;
clock = (time_t) Double_val(t);
- return alloc_tm(localtime(&clock));
+ tm = localtime(&clock);
+ if (tm == NULL) unix_error(EINVAL, "localtime", Nothing);
+ return alloc_tm(tm);
}
#ifdef HAS_MKTIME