]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Check for NULL pointer returned from localtime()/gmtime().
authorGuido van Rossum <guido@python.org>
Tue, 8 Oct 1996 14:19:52 +0000 (14:19 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 8 Oct 1996 14:19:52 +0000 (14:19 +0000)
Modules/timemodule.c

index aee599ae71a5239e7e70ed2882555f7b13dfdc41..6e6abfb2191dbe0835539e879532966cbfabcb25 100644 (file)
@@ -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 */