]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0557: valgrind reports possibly leaked memory v9.0.0557
authorBram Moolenaar <Bram@vim.org>
Fri, 23 Sep 2022 15:11:37 +0000 (16:11 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 23 Sep 2022 15:11:37 +0000 (16:11 +0100)
Problem:    Valgrind reports possibly leaked memory.
Solution:   Move the problematic test function to the "fails" test file to
            avoid obscuring real memory leaks.

src/testdir/test_vim9_fails.vim
src/testdir/test_vim9_func.vim
src/version.c

index 5c3cab545e42ab0d950b2ccd1ddb9d061e54df53..9d4337023592c8dd592dc4a27aac1ad5549b1259 100644 (file)
@@ -26,3 +26,37 @@ def Test_job_info_return_type()
   endif
 enddef
 
+" Using "idx" from a legacy global function does not work.
+" This caused a crash when called from legacy context.
+" This creates a dict that contains a partial that refers to the dict, causing
+" valgrind to report "possibly leaked memory".
+func Test_partial_call_fails()
+  let lines =<< trim END
+      vim9script
+
+      var l = ['a', 'b', 'c']
+      def Iter(container: any): any
+        var idx = -1
+        var obj = {state: container}
+        def g:NextItem__(self: dict<any>): any
+          ++idx
+          return self.state[idx]
+        enddef
+        obj.__next__ = function('g:NextItem__', [obj])
+        return obj
+      enddef
+
+      var it = Iter(l)
+      echo it.__next__()
+  END
+  call writefile(lines, 'XpartialCall', 'D')
+  let caught = 'no'
+  try
+    source XpartialCall
+  catch /E1248:/
+    let caught = 'yes'
+  endtry
+  call assert_equal('yes', caught)
+  delfunc g:NextItem__
+endfunc
+
index dc6b10439fd832c0ce5862815944217adcce91a8..a0c5e49757d6c6d89912194204b3a1076a44ad3a 100644 (file)
@@ -3532,34 +3532,6 @@ def Test_partial_null_function()
   v9.CheckDefAndScriptSuccess(lines)
 enddef
 
-" Using "idx" from a legacy global function does not work.
-" This caused a crash when called from legacy context.
-func Test_partial_call_fails()
-  let lines =<< trim END
-      vim9script
-
-      var l = ['a', 'b', 'c']
-      def Iter(container: any): any
-        var idx = -1
-        var obj = {state: container}
-        def g:NextItem__(self: dict<any>): any
-          ++idx
-          return self.state[idx]
-        enddef
-        obj.__next__ = function('g:NextItem__', [obj])
-        return obj
-      enddef
-
-      var it = Iter(l)
-      echo it.__next__()
-  END
-  call writefile(lines, 'XpartialCall', 'D')
-  try
-    source XpartialCall
-  catch /E1248:/
-  endtry
-endfunc
-
 def Test_cmd_modifier()
   tab echo '0'
   v9.CheckDefFailure(['5tab echo 3'], 'E16:')
index 8df30bd161942fcfb17eb8bf6561a53f84c27581..f01afe3862bebfb20769347f3a27b0f6745f5ff3 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    557,
 /**/
     556,
 /**/