changeset 25196:694f114a7673 v8.2.3134

patch 8.2.3134: crash when using typename() on a function reference Commit: https://github.com/vim/vim/commit/9da32e4d578f4e93ef5397f9dd13e2c28b2a2595 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jul 9 19:53:57 2021 +0200 patch 8.2.3134: crash when using typename() on a function reference Problem: Crash when using typename() on a function reference. (Naohiro Ono) Solution: Initialize pointer to NULL. (closes https://github.com/vim/vim/issues/8531)
author Bram Moolenaar <Bram@vim.org>
date Fri, 09 Jul 2021 20:00:04 +0200
parents f384b79d2eaa
children c8c0a86999f1
files src/testdir/test_vim9_builtin.vim src/version.c src/vim9type.c
diffstat 3 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -1943,6 +1943,12 @@ def Test_tr()
   CheckDefFailure(['echo tr("a", "a", 1)'], 'E1013: Argument 3: type mismatch, expected string but got number')
 enddef
 
+def Test_typename()
+  if has('float')
+    assert_equal('func([unknown], [unknown]): float', typename(function('pow')))
+  endif
+enddef
+
 def Test_undofile()
   CheckDefFailure(['undofile(10)'], 'E1013: Argument 1: type mismatch, expected string but got number')
   assert_equal('.abc.un~', fnamemodify(undofile('abc'), ':t'))
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3134,
+/**/
     3133,
 /**/
     3132,
--- a/src/vim9type.c
+++ b/src/vim9type.c
@@ -1166,7 +1166,7 @@ type_name(type_T *type, char **tofree)
 
 	for (i = 0; i < type->tt_argcount; ++i)
 	{
-	    char *arg_free;
+	    char *arg_free = NULL;
 	    char *arg_type;
 	    int  len;