parse: push_result_token: throw an exception on too-long names
Before this, such names would instead cause an assertion error inside qstr_from_strn. A simple reproducer is a python source file containing the letter "a" repeated 256 times
This commit is contained in:
parent
0c2894c725
commit
511c180869
@ -477,6 +477,9 @@ STATIC void push_result_token(parser_t *parser, uint8_t rule_id) {
|
|||||||
mp_parse_node_t pn;
|
mp_parse_node_t pn;
|
||||||
mp_lexer_t *lex = parser->lexer;
|
mp_lexer_t *lex = parser->lexer;
|
||||||
if (lex->tok_kind == MP_TOKEN_NAME) {
|
if (lex->tok_kind == MP_TOKEN_NAME) {
|
||||||
|
if(lex->vstr.len >= (1 << (8 * MICROPY_QSTR_BYTES_IN_LEN))) {
|
||||||
|
mp_raise_msg(&mp_type_SyntaxError, translate("Name too long"));
|
||||||
|
}
|
||||||
qstr id = qstr_from_strn(lex->vstr.buf, lex->vstr.len);
|
qstr id = qstr_from_strn(lex->vstr.buf, lex->vstr.len);
|
||||||
#if MICROPY_COMP_CONST
|
#if MICROPY_COMP_CONST
|
||||||
// if name is a standalone identifier, look it up in the table of dynamic constants
|
// if name is a standalone identifier, look it up in the table of dynamic constants
|
||||||
|
Loading…
Reference in New Issue
Block a user