comparison src/vim9execute.c @ 24065:a6aec9a89184 v8.2.2574

patch 8.2.2574: Vim9: crash when calling partial with wrong function Commit: https://github.com/vim/vim/commit/04947cc6ed313b6b99889c27d008c68a373df634 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 6 19:26:46 2021 +0100 patch 8.2.2574: Vim9: crash when calling partial with wrong function Problem: Vim9: crash when calling partial with wrong function. Solution: Check argument types of called function. (closes https://github.com/vim/vim/issues/7912)
author Bram Moolenaar <Bram@vim.org>
date Sat, 06 Mar 2021 19:30:02 +0100
parents e45b2e28e45e
children 5006d95ef82d
comparison
equal deleted inserted replaced
24064:85e18722945c 24065:a6aec9a89184
795 if (vim9_aborting(called_emsg_before)) 795 if (vim9_aborting(called_emsg_before))
796 return FAIL; // bail out if loading the script caused an error 796 return FAIL; // bail out if loading the script caused an error
797 } 797 }
798 798
799 if (ufunc != NULL) 799 if (ufunc != NULL)
800 {
801 if (ufunc->uf_arg_types != NULL)
802 {
803 int i;
804 typval_T *argv = STACK_TV_BOT(0) - argcount;
805
806 // The function can change at runtime, check that the argument
807 // types are correct.
808 for (i = 0; i < argcount; ++i)
809 {
810 type_T *type = i < ufunc->uf_args.ga_len
811 ? ufunc->uf_arg_types[i] : ufunc->uf_va_type;
812
813 if (type != NULL && check_typval_arg_type(type,
814 &argv[i], i + 1) == FAIL)
815 return FAIL;
816 }
817 }
818
800 return call_ufunc(ufunc, NULL, argcount, ectx, iptr); 819 return call_ufunc(ufunc, NULL, argcount, ectx, iptr);
820 }
801 821
802 return FAIL; 822 return FAIL;
803 } 823 }
804 824
805 static int 825 static int