diff Python/ast.c @ 39131:7c09b66f04bd legacy-trunk

Handle more memory allocation failures without crashing.
author Neal Norwitz <nnorwitz@gmail.com>
date Fri, 21 Jul 2006 07:59:47 +0000
parents 7182c2775c1e
children b745b3fd66a6
line wrap: on
line diff
--- a/Python/ast.c	Fri Jul 21 07:59:02 2006 +0000
+++ b/Python/ast.c	Fri Jul 21 07:59:47 2006 +0000
@@ -638,8 +638,10 @@
                    anything other than EQUAL or a comma? */
                 /* XXX Should NCH(n) check be made a separate check? */
                 if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) {
-                    asdl_seq_SET(defaults, j++, 
-				    ast_for_expr(c, CHILD(n, i + 2)));
+                    expr_ty expression = ast_for_expr(c, CHILD(n, i + 2));
+                    if (!expression)
+                            goto error;
+                    asdl_seq_SET(defaults, j++, expression);
                     i += 2;
 		    found_default = 1;
                 }