summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-05-14 21:48:09 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-05-14 21:48:09 (GMT)
commit42b5bcf048b274c7fdbb9fbabdb9f6f856031d08 (patch)
tree2ec639efed7820bcfd87b918d8fd574e294bdce4
parenteed30d830b26d325d04630cd5ee3af22f4d234da (diff)
downloadcpython-42b5bcf048b274c7fdbb9fbabdb9f6f856031d08.zip
cpython-42b5bcf048b274c7fdbb9fbabdb9f6f856031d08.tar.gz
cpython-42b5bcf048b274c7fdbb9fbabdb9f6f856031d08.tar.bz2
Issue #5918: Fix a crash in the parser module.
Patch by Amaury.
-rw-r--r--Misc/NEWS2
-rw-r--r--Modules/parsermodule.c4
2 files changed, 4 insertions, 2 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 58f381b..109297e 100644
--- 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
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
index 12b7fc3..a4a6416 100644
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -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)));