Commit 6e8583dc authored by Guido van Rossum's avatar Guido van Rossum

Check for NULL pointer returned from localtime()/gmtime().

parent c196202e
...@@ -135,7 +135,16 @@ time_convert(when, function) ...@@ -135,7 +135,16 @@ time_convert(when, function)
time_t when; time_t when;
struct tm * (*function) PROTO((const time_t *)); 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)", return mkvalue("(iiiiiiiii)",
p->tm_year + 1900, p->tm_year + 1900,
p->tm_mon + 1, /* Want January == 1 */ p->tm_mon + 1, /* Want January == 1 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment