summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-10-08 14:19:52 (GMT)
committerGuido van Rossum <guido@python.org>1996-10-08 14:19:52 (GMT)
commit6e8583dcb3c2da749349cc14621748c3920f07b2 (patch)
tree6381e896f59ad7a931298040862a963e15f4bb69
parentc196202e3d809be6d457b1ad06f13f4361e868aa (diff)
downloadcpython-6e8583dcb3c2da749349cc14621748c3920f07b2.zip
cpython-6e8583dcb3c2da749349cc14621748c3920f07b2.tar.gz
cpython-6e8583dcb3c2da749349cc14621748c3920f07b2.tar.bz2
Check for NULL pointer returned from localtime()/gmtime().
-rw-r--r--Modules/timemodule.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index aee599a..6e6abfb 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -135,7 +135,16 @@ time_convert(when, function)
time_t when;
struct tm * (*function) PROTO((const time_t *));
{
- struct tm *p = function(&when);
+ struct tm *p;
+ errno = 0;
+ p = function(&when);
+ if (p == NULL) {
+#ifdef EINVAL
+ if (errno == NULL)
+ errno = EINVAL;
+#endif
+ return err_errno(IOError);
+ }
return mkvalue("(iiiiiiiii)",
p->tm_year + 1900,
p->tm_mon + 1, /* Want January == 1 */