]> granicus.if.org Git - python/commitdiff
Coverity-found bug: datetime_strptime() failed to check for NULL return from
authorThomas Wouters <thomas@python.org>
Fri, 14 Apr 2006 21:23:42 +0000 (21:23 +0000)
committerThomas Wouters <thomas@python.org>
Fri, 14 Apr 2006 21:23:42 +0000 (21:23 +0000)
PySequence_GetItem of the time.strptime() result. Not a high probability
bug, but not inconceivable either, considering people can provide their own
'time' module.

Modules/datetimemodule.c

index 68231101858790ad9217a7480da1c9c8b4432cff..a8fa4e7d03bf37b967db0261540c941a029cfd2e 100644 (file)
@@ -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