summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2005-11-20 23:58:38 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2005-11-20 23:58:38 (GMT)
commit7bcabc60a36eb5910bd162d54ece449f5249bbcd (patch)
treecef5c71fedb71b1e9d24df5f58bded565ba1691d /Python
parent4aef41ffe7bee84f3b6440f4d76099cd030d058b (diff)
downloadcpython-7bcabc60a36eb5910bd162d54ece449f5249bbcd.zip
cpython-7bcabc60a36eb5910bd162d54ece449f5249bbcd.tar.gz
cpython-7bcabc60a36eb5910bd162d54ece449f5249bbcd.tar.bz2
Fix a few more memory leaks
Document more info about the benefits of configuring without pymalloc when running valgrind
Diffstat (limited to 'Python')
-rw-r--r--Python/ast.c12
-rw-r--r--Python/compile.c3
-rw-r--r--Python/modsupport.c1
3 files changed, 14 insertions, 2 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 87a9a4b..731bf9a 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -1054,8 +1054,12 @@ ast_for_listcomp(struct compiling *c, const node *n)
return NULL;
}
- if (asdl_seq_LEN(t) == 1)
+ if (asdl_seq_LEN(t) == 1) {
lc = comprehension(asdl_seq_GET(t, 0), expression, NULL);
+ /* only free the sequence since we grabbed element 0 above */
+ if (lc)
+ asdl_seq_free(t); /* ok */
+ }
else
lc = comprehension(Tuple(t, Store, LINENO(ch)), expression, NULL);
@@ -1222,9 +1226,13 @@ ast_for_genexp(struct compiling *c, const node *n)
return NULL;
}
- if (asdl_seq_LEN(t) == 1)
+ if (asdl_seq_LEN(t) == 1) {
ge = comprehension(asdl_seq_GET(t, 0), expression,
NULL);
+ /* only free the sequence since we grabbed element 0 above */
+ if (ge)
+ asdl_seq_free(t); /* ok */
+ }
else
ge = comprehension(Tuple(t, Store, LINENO(ch)),
expression, NULL);
diff --git a/Python/compile.c b/Python/compile.c
index 4d637ae..5905c45 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -2384,7 +2384,10 @@ compiler_import_as(struct compiler *c, identifier name, identifier asname)
dot = strchr(src, '.');
attr = PyString_FromStringAndSize(src,
dot ? dot - src : strlen(src));
+ if (!attr)
+ return -1;
ADDOP_O(c, LOAD_ATTR, attr, names);
+ Py_DECREF(attr);
src = dot + 1;
}
}
diff --git a/Python/modsupport.c b/Python/modsupport.c
index 197d99b..fbfb48d 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -82,6 +82,7 @@ Py_InitModule4(char *name, PyMethodDef *methods, char *doc,
}
Py_DECREF(v);
}
+ Py_DECREF(n);
}
if (doc != NULL) {
v = PyString_FromString(doc);