From 7bcabc60a36eb5910bd162d54ece449f5249bbcd Mon Sep 17 00:00:00 2001 From: Neal Norwitz Date: Sun, 20 Nov 2005 23:58:38 +0000 Subject: Fix a few more memory leaks Document more info about the benefits of configuring without pymalloc when running valgrind --- Python/ast.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Python/ast.c') diff --git a/Python/ast.c b/Python/ast.c index 87a9a4b3a09..731bf9a4917 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); -- cgit v1.2.3