From e81dc296f287ca20ebfebda8de2fbcca5580d666 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 10 Sep 2012 16:57:36 +0200 Subject: [PATCH] Fixed memory leak in error branch of object_repr which may leak a reference to mod when type_name returns NULL. CID 715371 --- Objects/typeobject.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index e34b10ce40a..0fc0ad38e82 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2925,8 +2925,10 @@ object_repr(PyObject *self) mod = NULL; } name = type_name(type, NULL); - if (name == NULL) + if (name == NULL) { + Py_XDECREF(mod); return NULL; + } if (mod != NULL && PyUnicode_CompareWithASCIIString(mod, "builtins")) rtn = PyUnicode_FromFormat("<%U.%U object at %p>", mod, name, self); else