]> granicus.if.org Git - python/commitdiff
Backport r60246.
authorGuido van Rossum <guido@python.org>
Thu, 24 Jan 2008 17:59:56 +0000 (17:59 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 24 Jan 2008 17:59:56 +0000 (17:59 +0000)
Fix issue #1303614, test67.py.

Objects/object.c

index b0672f30e65df0ac33a1187e9d0e6e3a899d0968..71e5641e969129bea7e228ae3f46ba7e83342afc 100644 (file)
@@ -1335,12 +1335,15 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
                dictptr = (PyObject **) ((char *)obj + dictoffset);
                dict = *dictptr;
                if (dict != NULL) {
+                       Py_INCREF(dict);
                        res = PyDict_GetItem(dict, name);
                        if (res != NULL) {
                                Py_INCREF(res);
                                Py_XDECREF(descr);
+                                Py_DECREF(dict);
                                goto done;
                        }
+                        Py_DECREF(dict);
                }
        }
 
@@ -1421,12 +1424,14 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
                        *dictptr = dict;
                }
                if (dict != NULL) {
+                       Py_INCREF(dict);
                        if (value == NULL)
                                res = PyDict_DelItem(dict, name);
                        else
                                res = PyDict_SetItem(dict, name, value);
                        if (res < 0 && PyErr_ExceptionMatches(PyExc_KeyError))
                                PyErr_SetObject(PyExc_AttributeError, name);
+                       Py_DECREF(dict);
                        goto done;
                }
        }