Skip to content

Commit 150eef2

Browse files
author
thomas.wouters
committed
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. git-svn-id: http://svn.python.org/projects/python/trunk@45408 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent a8cb3e7 commit 150eef2

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Modules/datetimemodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3825,6 +3825,10 @@ datetime_strptime(PyObject *cls, PyObject *args)
38253825
if (PySequence_Check(obj) && PySequence_Size(obj) >= 6)
38263826
for (i=0; i < 6; i++) {
38273827
PyObject *p = PySequence_GetItem(obj, i);
3828+
if (p == NULL) {
3829+
Py_DECREF(obj);
3830+
return NULL;
3831+
}
38283832
if (PyInt_Check(p))
38293833
ia[i] = PyInt_AsLong(p);
38303834
else

0 commit comments

Comments
 (0)