From: Thomas Wouters Date: Fri, 14 Apr 2006 21:23:42 +0000 (+0000) Subject: Coverity-found bug: datetime_strptime() failed to check for NULL return from X-Git-Tag: v2.5a2~224 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3cfea2dc987b90e637c4cbd5db5dc1f542e448b2;p=thirdparty%2FPython%2Fcpython.git Coverity-found bug: datetime_strptime() failed to check for NULL return from PySequence_GetItem of the time.strptime() result. Not a high probability bug, but not inconceivable either, considering people can provide their own 'time' module. --- diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c index 682311018587..a8fa4e7d03bf 100644 --- a/Modules/datetimemodule.c +++ b/Modules/datetimemodule.c @@ -3825,6 +3825,10 @@ datetime_strptime(PyObject *cls, PyObject *args) if (PySequence_Check(obj) && PySequence_Size(obj) >= 6) for (i=0; i < 6; i++) { PyObject *p = PySequence_GetItem(obj, i); + if (p == NULL) { + Py_DECREF(obj); + return NULL; + } if (PyInt_Check(p)) ia[i] = PyInt_AsLong(p); else