[Python-checkins] python/dist/src/Python compile.c, 2.247.2.5, 2.247.2.6
nnorwitz@users.sourceforge.net
nnorwitz at users.sourceforge.net
Wed Oct 19 08:31:40 CEST 2005
Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16668/Python
Modified Files:
Tag: ast-branch
compile.c
Log Message:
Fix memory leaks in error conditions
Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.247.2.5
retrieving revision 2.247.2.6
diff -u -d -r2.247.2.5 -r2.247.2.6
--- compile.c 18 Oct 2005 13:36:07 -0000 2.247.2.5
+++ compile.c 19 Oct 2005 06:31:37 -0000 2.247.2.6
@@ -1060,6 +1060,9 @@
struct compiler_unit *u;
u = PyObject_Malloc(sizeof(struct compiler_unit));
+ if (!u)
+ return 0;
+
memset(u, 0, sizeof(struct compiler_unit));
u->u_argcount = 0;
u->u_ste = PySymtable_Lookup(c->c_st, key);
@@ -1070,9 +1073,21 @@
Py_INCREF(name);
u->u_name = name;
u->u_varnames = list2dict(u->u_ste->ste_varnames);
+ if (!u->u_varnames) {
+ compiler_unit_free(u);
+ return 0;
+ }
u->u_cellvars = dictbytype(u->u_ste->ste_symbols, CELL, 0, 0);
+ if (!u->u_cellvars) {
+ compiler_unit_free(u);
+ return 0;
+ }
u->u_freevars = dictbytype(u->u_ste->ste_symbols, FREE, DEF_FREE_CLASS,
PyDict_Size(u->u_cellvars));
+ if (!u->u_freevars) {
+ compiler_unit_free(u);
+ return 0;
+ }
u->u_blocks = NULL;
u->u_tmpname = 0;
More information about the Python-checkins
mailing list