From: Christian Heimes Date: Mon, 22 Jul 2013 08:30:14 +0000 (+0200) Subject: Add sanity check to PyGrammar_LabelRepr() in order to catch invalid tokens when debugging X-Git-Tag: v3.4.0a1~110^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=53d2dc4045f6793d166b2806d7726c45cdea74e4;p=thirdparty%2FPython%2Fcpython.git Add sanity check to PyGrammar_LabelRepr() in order to catch invalid tokens when debugging a new grammar. CID 715360 --- diff --git a/Parser/grammar1.c b/Parser/grammar1.c index 1f7d264be927..17e2ba9f926b 100644 --- a/Parser/grammar1.c +++ b/Parser/grammar1.c @@ -45,7 +45,7 @@ PyGrammar_LabelRepr(label *lb) else return lb->lb_str; } - else { + else if (lb->lb_type < N_TOKENS) { if (lb->lb_str == NULL) return _PyParser_TokenNames[lb->lb_type]; else { @@ -54,4 +54,7 @@ PyGrammar_LabelRepr(label *lb) return buf; } } + else { + Py_FatalError("invalid label"); + } }