@@ -1901,13 +1901,15 @@ ast_for_expr_stmt(struct compiling *c, const node *n)
19011901 if (!expr1 )
19021902 return NULL ;
19031903 if (expr1 -> kind == GeneratorExp_kind ) {
1904+ free_expr (expr1 );
19041905 ast_error (ch , "augmented assignment to generator "
19051906 "expression not possible" );
19061907 return NULL ;
19071908 }
19081909 if (expr1 -> kind == Name_kind ) {
19091910 char * var_name = PyString_AS_STRING (expr1 -> v .Name .id );
19101911 if (var_name [0 ] == 'N' && !strcmp (var_name , "None" )) {
1912+ free_expr (expr1 );
19111913 ast_error (ch , "assignment to None" );
19121914 return NULL ;
19131915 }
@@ -1918,12 +1920,17 @@ ast_for_expr_stmt(struct compiling *c, const node *n)
19181920 expr2 = ast_for_testlist (c , ch );
19191921 else
19201922 expr2 = Yield (ast_for_expr (c , ch ), LINENO (ch ));
1921- if (!expr2 )
1923+ if (!expr2 ) {
1924+ free_expr (expr1 );
19221925 return NULL ;
1926+ }
19231927
19241928 operator = ast_for_augassign (CHILD (n , 1 ));
1925- if (!operator )
1929+ if (!operator ) {
1930+ free_expr (expr1 );
1931+ free_expr (expr2 );
19261932 return NULL ;
1933+ }
19271934
19281935 return AugAssign (expr1 , operator , expr2 , LINENO (n ));
19291936 }
@@ -1964,7 +1971,7 @@ ast_for_expr_stmt(struct compiling *c, const node *n)
19641971 else
19651972 expression = ast_for_expr (c , value );
19661973 if (!expression )
1967- return NULL ;
1974+ goto error ;
19681975 return Assign (targets , expression , LINENO (n ));
19691976 error :
19701977 for (i = i / 2 ; i >= 0 ; i -- )
0 commit comments