[k-takata/Onigmo] Fix stack overflow with X+++++++++++++++++++…

Imported the fix from:
4097828d7c

https://github.com/k-takata/Onigmo/commit/786b4849c1
This commit is contained in:
K.Takata 2019-07-29 20:16:46 +09:00 committed by Nobuyoshi Nakada
parent f0b31a5898
commit ac379278e8
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
Notes: git 2026-01-12 12:35:30 +00:00

View File

@ -6313,11 +6313,14 @@ parse_exp(Node** np, OnigToken* tok, int term,
int r, len, group = 0; int r, len, group = 0;
Node* qn; Node* qn;
Node** targetp; Node** targetp;
unsigned int parse_depth;
*np = NULL; *np = NULL;
if (tok->type == (enum TokenSyms )term) if (tok->type == (enum TokenSyms )term)
goto end_of_token; goto end_of_token;
parse_depth = env->parse_depth;
switch (tok->type) { switch (tok->type) {
case TK_ALT: case TK_ALT:
case TK_EOT: case TK_EOT:
@ -6628,6 +6631,10 @@ parse_exp(Node** np, OnigToken* tok, int term,
if (is_invalid_quantifier_target(*targetp)) if (is_invalid_quantifier_target(*targetp))
return ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID; return ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID;
parse_depth++;
if (parse_depth > ParseDepthLimit)
return ONIGERR_PARSE_DEPTH_LIMIT_OVER;
qn = node_new_quantifier(tok->u.repeat.lower, tok->u.repeat.upper, qn = node_new_quantifier(tok->u.repeat.lower, tok->u.repeat.upper,
(r == TK_INTERVAL ? 1 : 0)); (r == TK_INTERVAL ? 1 : 0));
CHECK_NULL_RETURN_MEMERR(qn); CHECK_NULL_RETURN_MEMERR(qn);