summaryrefslogtreecommitdiffstats
path: root/Python/Python-ast.c
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 /Python/Python-ast.c
parent26cc63f867237e2d096b9a326d591e6b5c30a771 (diff)
downloadcpython-03e5bc02c9744640f4d228ff7686c2392ab17812.zip
cpython-03e5bc02c9744640f4d228ff7686c2392ab17812.tar.gz
cpython-03e5bc02c9744640f4d228ff7686c2392ab17812.tar.bz2
Fix memory leak on attributes.
Diffstat (limited to 'Python/Python-ast.c')
-rw-r--r--Python/Python-ast.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 3e49212..3f8345e 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -2324,10 +2324,14 @@ ast2obj_stmt(void* _o)
}
value = ast2obj_int(o->lineno);
if (!value) goto failed;
- PyObject_SetAttrString(result, "lineno", value);
+ if (PyObject_SetAttrString(result, "lineno", value) < 0)
+ goto failed;
+ Py_DECREF(value);
value = ast2obj_int(o->col_offset);
if (!value) goto failed;
- PyObject_SetAttrString(result, "col_offset", value);
+ if (PyObject_SetAttrString(result, "col_offset", value) < 0)
+ goto failed;
+ Py_DECREF(value);
return result;
failed:
Py_XDECREF(value);
@@ -2643,10 +2647,14 @@ ast2obj_expr(void* _o)
}
value = ast2obj_int(o->lineno);
if (!value) goto failed;
- PyObject_SetAttrString(result, "lineno", value);
+ if (PyObject_SetAttrString(result, "lineno", value) < 0)
+ goto failed;
+ Py_DECREF(value);
value = ast2obj_int(o->col_offset);
if (!value) goto failed;
- PyObject_SetAttrString(result, "col_offset", value);
+ if (PyObject_SetAttrString(result, "col_offset", value) < 0)
+ goto failed;
+ Py_DECREF(value);
return result;
failed:
Py_XDECREF(value);
@@ -3023,7 +3031,7 @@ init_ast(void)
if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return;
if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0)
return;
- if (PyModule_AddStringConstant(m, "__version__", "42649") < 0)
+ if (PyModule_AddStringConstant(m, "__version__", "42753") < 0)
return;
if(PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return;
if(PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0)