diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 1999-10-14 13:52:13 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 1999-10-14 13:52:13 +0000 |
commit | bffcd916c133f29b464e0255df6dcfe95b82db48 (patch) | |
tree | 9f0a9807cb591eb324971d79da2e312879084f44 /otherlibs/unix | |
parent | 7838462bd080707287c2948cf04e228cc9e58477 (diff) |
Traiter le cas ou gmtime et localtime renvoient NULL
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2428 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/unix')
-rw-r--r-- | otherlibs/unix/gmtime.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/otherlibs/unix/gmtime.c b/otherlibs/unix/gmtime.c index 0ecf8b99b..b7c8b28a2 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 |