]> granicus.if.org Git - python/commitdiff
Fix a usage of the dangerous pattern decref - modify field - incref.
authorArmin Rigo <arigo@tunes.org>
Thu, 19 Apr 2007 14:56:48 +0000 (14:56 +0000)
committerArmin Rigo <arigo@tunes.org>
Thu, 19 Apr 2007 14:56:48 +0000 (14:56 +0000)
Objects/typeobject.c

index a3b1476a8d50c416d5b59e447ab9bebceac8baf4..89d2d4f98138703c819ff0386b12a42575a7b6f6 100644 (file)
@@ -265,9 +265,10 @@ type_set_bases(PyTypeObject *type, PyObject *value, void *context)
                        PyObject* mro;
                        PyArg_UnpackTuple(PyList_GET_ITEM(temp, i),
                                         "", 2, 2, &cls, &mro);
-                       Py_DECREF(cls->tp_mro);
+                       Py_INCREF(mro);
+                       ob = cls->tp_mro;
                        cls->tp_mro = mro;
-                       Py_INCREF(cls->tp_mro);
+                       Py_DECREF(ob);
                }
                Py_DECREF(temp);
                goto bail;