From 1afec5d6bf1f0e5d0cb62e633c69ed37e2f03a9c Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Wed, 27 May 2009 03:08:44 +0000 Subject: [PATCH] plug ref leak --- Objects/dictobject.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Objects/dictobject.c b/Objects/dictobject.c index dbf6411b986..c4e6aa58672 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -1153,14 +1153,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; }