diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-10-27 13:07:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-27 13:07:24 +0800 |
commit | 1fe31651bce5021ea6d6dfe6fa426fde7795a77f (patch) | |
tree | f62ed2f8b299b9886b1ec158477111525032c581 /src/nvim/eval.c | |
parent | 7765f2bb8304631c00f1e00ffc73c18cd4d22601 (diff) | |
parent | e3acf913db7eb27d53ea8f91b70fb2c723796be9 (diff) | |
download | rneovim-1fe31651bce5021ea6d6dfe6fa426fde7795a77f.tar.gz rneovim-1fe31651bce5021ea6d6dfe6fa426fde7795a77f.tar.bz2 rneovim-1fe31651bce5021ea6d6dfe6fa426fde7795a77f.zip |
Merge pull request #20826 from zeertzjq/vim-8.2.4206
vim-patch:8.2.{4070,4206,4207}
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 8bd91ec9a2..0e4dbeaea6 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -65,6 +65,7 @@ static char *e_nowhitespace = N_("E274: No white space allowed before parenthesis"); static char *e_write2 = N_("E80: Error while writing: %s"); static char *e_string_list_or_blob_required = N_("E1098: String, List or Blob required"); +static char e_expression_too_recursive_str[] = N_("E1169: Expression too recursive: %s"); static char * const namespace_char = "abglstvw"; @@ -2911,6 +2912,7 @@ static int eval7(char **arg, typval_T *rettv, int evaluate, int want_string) const char *start_leader, *end_leader; int ret = OK; char *alias; + static int recurse = 0; // Initialise variable so that tv_clear() can't mistake this for a // string and free a string that isn't there. @@ -2923,6 +2925,20 @@ static int eval7(char **arg, typval_T *rettv, int evaluate, int want_string) } end_leader = *arg; + // Limit recursion to 1000 levels. At least at 10000 we run out of stack + // and crash. With MSVC the stack is smaller. + if (recurse == +#ifdef _MSC_VER + 300 +#else + 1000 +#endif + ) { + semsg(_(e_expression_too_recursive_str), *arg); + return FAIL; + } + recurse++; + switch (**arg) { // Number constant. case '0': @@ -3127,6 +3143,8 @@ static int eval7(char **arg, typval_T *rettv, int evaluate, int want_string) if (ret == OK && evaluate && end_leader > start_leader) { ret = eval7_leader(rettv, (char *)start_leader, &end_leader); } + + recurse--; return ret; } |