summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-03-02 00:31:27 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2006-03-02 00:31:27 (GMT)
commit03e5bc02c9744640f4d228ff7686c2392ab17812 (patch)
tree1a7d307c177e6c643e4a6c0ebe37ee204bafa3ff /Parser
parent26cc63f867237e2d096b9a326d591e6b5c30a771 (diff)
downloadcpython-03e5bc02c9744640f4d228ff7686c2392ab17812.zip
cpython-03e5bc02c9744640f4d228ff7686c2392ab17812.tar.gz
cpython-03e5bc02c9744640f4d228ff7686c2392ab17812.tar.bz2
Fix memory leak on attributes.
Diffstat (limited to 'Parser')
-rwxr-xr-xParser/asdl_c.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 3e2acf4..ad2209d 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):