Ticket #270, CEnumDefNode leaks memory during construction
authorRobert Bradshaw <robertwb@math.washington.edu>
Fri, 10 Apr 2009 06:05:40 +0000 (23:05 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Fri, 10 Apr 2009 06:05:40 +0000 (23:05 -0700)
Cython/Compiler/Nodes.py

index a51027c6d8c61b57bde3315579f0b2c6adc24238..eadcab117ae901c373cff92247de286934521578 100644 (file)
@@ -916,12 +916,13 @@ class CEnumDefNode(StatNode):
                         self.temp,
                         item.cname,
                         code.error_goto_if_null(self.temp, item.pos)))
+                code.put_gotref(self.temp)
                 code.putln('if (__Pyx_SetAttrString(%s, "%s", %s) < 0) %s' % (
                         Naming.module_cname, 
                         item.name, 
                         self.temp,
                         code.error_goto(item.pos)))
-                code.putln("%s = 0;" % self.temp)
+                code.put_decref_clear(self.temp, PyrexTypes.py_object_type)
 
 
 class CEnumDefItemNode(StatNode):