]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add sanity check to PyGrammar_LabelRepr() in order to catch invalid tokens when debugging
authorChristian Heimes <christian@cheimes.de>
Mon, 22 Jul 2013 08:30:14 +0000 (10:30 +0200)
committerChristian Heimes <christian@cheimes.de>
Mon, 22 Jul 2013 08:30:14 +0000 (10:30 +0200)
a new grammar.
CID 715360

Parser/grammar1.c

index 1f7d264be927e95080b02dfbf0b1417c98053fa9..17e2ba9f926b8559718e9b8c944960af74bbe8fd 100644 (file)
@@ -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");
+    }
 }