]> granicus.if.org Git - python/commitdiff
Issue #5918: Fix a crash in the parser module.
authorAntoine Pitrou <solipsis@pitrou.net>
Thu, 14 May 2009 21:48:09 +0000 (21:48 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Thu, 14 May 2009 21:48:09 +0000 (21:48 +0000)
Patch by Amaury.

Misc/NEWS
Modules/parsermodule.c

index 58f381b45d4edff2f1130d2f94669330a7217657..109297ec8a86992186c0b4d9ece1c13644e5dff8 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -293,6 +293,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #5918: Fix a crash in the parser module.
+
 - Issue #1664: Make nntplib IPv6-capable. Patch by Derek Morr.
 
 - Issue #6022: a test file was created in the current working directory by
index 12b7fc3c5b537ebd53eee49dad4b401522e9f6bb..a4a641662f3b6363464ba98fdde31aa875c4621b 100644 (file)
@@ -2092,14 +2092,14 @@ validate_try(node *tree)
         return (res);
     }
     /* try/except statement: skip past except_clause sections */
-    while (res && (TYPE(CHILD(tree, pos)) == except_clause)) {
+    while (res && pos < nch && (TYPE(CHILD(tree, pos)) == except_clause)) {
         res = (validate_except_clause(CHILD(tree, pos))
                && validate_colon(CHILD(tree, pos + 1))
                && validate_suite(CHILD(tree, pos + 2)));
         pos += 3;
     }
     /* skip else clause */
-    if (res && (TYPE(CHILD(tree, pos)) == NAME) &&
+    if (res && pos < nch && (TYPE(CHILD(tree, pos)) == NAME) &&
         (strcmp(STR(CHILD(tree, pos)), "else") == 0)) {
         res = (validate_colon(CHILD(tree, pos + 1))
                && validate_suite(CHILD(tree, pos + 2)));