]> granicus.if.org Git - python/commitdiff
Merged revisions 72958 via svnmerge from
authorBenjamin Peterson <benjamin@python.org>
Wed, 27 May 2009 03:18:19 +0000 (03:18 +0000)
committerBenjamin Peterson <benjamin@python.org>
Wed, 27 May 2009 03:18:19 +0000 (03:18 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72958 | benjamin.peterson | 2009-05-26 22:08:44 -0500 (Tue, 26 May 2009) | 1 line

  plug ref leak
........

Objects/dictobject.c

index 97fa60b22217599bc5a040e2baa655b7b834366e..f21cea24c3d6a8b1beb9ad640870e937727147e5 100644 (file)
@@ -1126,14 +1126,17 @@ dict_subscript(PyDictObject *mp, register PyObject *key)
        if (v == NULL) {
                if (!PyDict_CheckExact(mp)) {
                        /* Look up __missing__ method if we're a subclass. */
-                       PyObject *missing;
+                       PyObject *missing, *res;
                        static PyObject *missing_str = NULL;
                        missing = _PyObject_LookupSpecial((PyObject *)mp,
                                                          "__missing__",
                                                          &missing_str);
-                       if (missing != NULL)
-                               return PyObject_CallFunctionObjArgs(missing,
-                                       key, NULL);
+                       if (missing != NULL) {
+                               res = PyObject_CallFunctionObjArgs(missing,
+                                                                  key, NULL);
+                               Py_DECREF(missing);
+                               return res;
+                       }
                        else if (PyErr_Occurred())
                                return NULL;
                }