[Python-checkins] commit of r41441 - python/trunk/Python

neal.norwitz@python.org neal.norwitz at python.org
Mon Nov 14 01:18:05 CET 2005


Author: neal.norwitz
Date: Mon Nov 14 01:18:03 2005
New Revision: 41441
Modified:
 python/trunk/Python/ast.c
Log:
Fix memory leak with bad generator expression
Modified: python/trunk/Python/ast.c
==============================================================================
--- python/trunk/Python/ast.c	(original)
+++ python/trunk/Python/ast.c	Mon Nov 14 01:18:03 2005
@@ -1901,6 +1901,7 @@
 if (!expr1)
 return NULL;
 if (expr1->kind == GeneratorExp_kind) {
+	 free_expr(expr1);
 	 ast_error(ch, "augmented assignment to generator "
 		 "expression not possible");
 	 return NULL;
@@ -1908,6 +1909,7 @@
 	if (expr1->kind == Name_kind) {
 		char *var_name = PyString_AS_STRING(expr1->v.Name.id);
 		if (var_name[0] == 'N' && !strcmp(var_name, "None")) {
+			free_expr(expr1);
 			ast_error(ch, "assignment to None");
 			return NULL;
 		}
@@ -1918,12 +1920,17 @@
 	 expr2 = ast_for_testlist(c, ch);
 	else
 	 expr2 = Yield(ast_for_expr(c, ch), LINENO(ch));
- if (!expr2)
+ if (!expr2) {
+ free_expr(expr1);
 return NULL;
+ }
 
 operator = ast_for_augassign(CHILD(n, 1));
- if (!operator)
+ if (!operator) {
+ free_expr(expr1);
+ free_expr(expr2);
 return NULL;
+ }
 
 	return AugAssign(expr1, operator, expr2, LINENO(n));
 }
@@ -1964,7 +1971,7 @@
 	else
 	 expression = ast_for_expr(c, value);
 	if (!expression)
-	 return NULL;
+	 goto error;
 	return Assign(targets, expression, LINENO(n));
 error:
 for (i = i / 2; i >= 0; i--)


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /