From e6964c67a6ce21aa14dc39d6b9fadc0160e30f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Thu, 2 Mar 2006 00:31:27 +0000 Subject: Fix memory leak on attributes. --- Parser/asdl_c.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Parser') diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index 3e2acf4372..ad2209d003 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -607,7 +607,9 @@ class ObjVisitor(PickleVisitor): for a in sum.attributes: self.emit("value = ast2obj_%s(o->%s);" % (a.type, a.name), 1) self.emit("if (!value) goto failed;", 1) - self.emit('PyObject_SetAttrString(result, "%s", value);' % a.name, 1) + self.emit('if (PyObject_SetAttrString(result, "%s", value) < 0)' % a.name, 1) + self.emit('goto failed;', 2) + self.emit('Py_DECREF(value);', 1) self.func_end() def simpleSum(self, sum, name): -- cgit v1.2.1