diff Python/ast.c @ 36001:6321669f2f4d legacy-trunk

SF #1377897, Bus error in ast If a line had multiple semi-colons and ended with a semi-colon, we would loop too many times and access a NULL node. Exit the loop early if there are no more children.
author Neal Norwitz <nnorwitz@gmail.com>
date Sun, 11 Dec 2005 20:12:40 +0000
parents cc3261597136
children ea083efdc96c
line wrap: on
line diff
--- a/Python/ast.c	Sun Dec 11 20:08:33 2005 +0000
+++ b/Python/ast.c	Sun Dec 11 20:12:40 2005 +0000
@@ -2562,6 +2562,11 @@
 		ch = CHILD(ch, 0);
 		REQ(ch, simple_stmt);
 		for (j = 0; j < NCH(ch); j += 2) {
+		    /* statement terminates with a semi-colon ';' */
+		    if (NCH(CHILD(ch, j)) == 0) {
+		    	assert((j + 1) == NCH(ch));
+		    	break;
+		    }
 		    s = ast_for_stmt(c, CHILD(ch, j));
 		    if (!s)
 			goto error;