diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-01-24 18:16:12 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-01-24 18:16:12 +0000 |
commit | fe6fb267e6ee5c5da2f41889e4e0e0ac5bf4b89d (patch) | |
tree | d37a272112c2a7b6f399d2210a9aa68b82eafe05 /src/eval.c | |
parent | 46634350740d062fc7e555fd6c5d4d43798d4df7 (diff) | |
download | vim-git-fe6fb267e6ee5c5da2f41889e4e0e0ac5bf4b89d.tar.gz |
patch 8.2.4206: condition with many "(" causes a crashv8.2.4206
Problem: Condition with many "(" causes a crash.
Solution: Limit recursion to 1000.
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c index 2ca337749..d42e1f826 100644 --- a/src/eval.c +++ b/src/eval.c @@ -3526,6 +3526,7 @@ eval7( char_u *start_leader, *end_leader; int ret = OK; char_u *alias; + static int recurse = 0; /* * Initialise variable so that clear_tv() can't mistake this for a @@ -3552,6 +3553,15 @@ eval7( return FAIL; } + // Limit recursion to 1000 levels. At least at 10000 we run out of stack + // and crash. + if (recurse == 1000) + { + semsg(_(e_expression_too_recursive_str), *arg); + return FAIL; + } + ++recurse; + switch (**arg) { /* @@ -3781,6 +3791,8 @@ eval7( */ if (ret == OK && evaluate && end_leader > start_leader) ret = eval7_leader(rettv, FALSE, start_leader, &end_leader); + + --recurse; return ret; } |