From: Guido van Rossum Date: Tue, 8 Oct 1996 14:19:52 +0000 (+0000) Subject: Check for NULL pointer returned from localtime()/gmtime(). X-Git-Tag: v1.4~132 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6e8583dcb3c2da749349cc14621748c3920f07b2;p=thirdparty%2FPython%2Fcpython.git Check for NULL pointer returned from localtime()/gmtime(). --- diff --git a/Modules/timemodule.c b/Modules/timemodule.c index aee599ae71a5..6e6abfb2191d 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 */