]> granicus.if.org Git - vim/commitdiff
patch 8.2.0061: the execute stack can grow big and never shrinks v8.2.0061
authorBram Moolenaar <Bram@vim.org>
Mon, 30 Dec 2019 18:19:53 +0000 (19:19 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 30 Dec 2019 18:19:53 +0000 (19:19 +0100)
Problem:    The execute stack can grow big and never shrinks.
Solution:   Reduce the size in gargage collect.

src/eval.c
src/version.c

index c03372d1c906e63de6eb0fe332f0a7b364c5a94d..739c73c9b6199f4bc6a5bf554db0f799f4ceaca6 100644 (file)
@@ -3857,6 +3857,30 @@ garbage_collect(int testing)
        garbage_collect_at_exit = FALSE;
     }
 
+    // The execution stack can grow big, limit the size.
+    if (exestack.ga_maxlen - exestack.ga_len > 500)
+    {
+       size_t  new_len;
+       char_u  *pp;
+       int     n;
+
+       // Keep 150% of the current size, with a minimum of the growth size.
+       n = exestack.ga_len / 2;
+       if (n < exestack.ga_growsize)
+           n = exestack.ga_growsize;
+
+       // Don't make it bigger though.
+       if (exestack.ga_len + n < exestack.ga_maxlen)
+       {
+           new_len = exestack.ga_itemsize * (exestack.ga_len + n);
+           pp = vim_realloc(exestack.ga_data, new_len);
+           if (pp == NULL)
+               return FAIL;
+           exestack.ga_maxlen = exestack.ga_len + n;
+           exestack.ga_data = pp;
+       }
+    }
+
     // We advance by two because we add one for items referenced through
     // previous_funccal.
     copyID = get_copyID();
index 3a22ca41d8bafbf2df2f3918dc064f447d0b04ca..f68e29fe4f73c2e1b05271b9687412a065e06522 100644 (file)
@@ -742,6 +742,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    61,
 /**/
     60,
 /**/