diff src/alloc.c @ 28382:f24d4826e6bf v8.2.4716

patch 8.2.4716: memory allocation failure not tested when defining a function Commit: https://github.com/vim/vim/commit/7c7e19cf50d76568e2637ad66b095044a41c6a82 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sat Apr 9 11:09:07 2022 +0100 patch 8.2.4716: memory allocation failure not tested when defining a function Problem: Memory allocation failure not tested when defining a function. Solution: Add a test. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/10127)
author Bram Moolenaar <Bram@vim.org>
date Sat, 09 Apr 2022 12:15:02 +0200
parents ff649d0078d6
children 3626ca6a20ea
line wrap: on
line diff
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -719,6 +719,20 @@ ga_grow(garray_T *gap, int n)
     return OK;
 }
 
+/*
+ * Same as ga_grow() but uses an allocation id for testing.
+ */
+    int
+ga_grow_id(garray_T *gap, int n, alloc_id_T id UNUSED)
+{
+#ifdef FEAT_EVAL
+    if (alloc_fail_id == id && alloc_does_fail(sizeof(list_T)))
+	return FAIL;
+#endif
+
+    return ga_grow(gap, n);
+}
+
     int
 ga_grow_inner(garray_T *gap, int n)
 {