Mercurial > vim
comparison src/scriptfile.c @ 21206:caab594592cc v8.2.1154
patch 8.2.1154: Vim9: crash when using imported function
Commit: https://github.com/vim/vim/commit/c620c055ce8505596a7208ba696a32b8a3be4f4b
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jul 8 15:16:19 2020 +0200
patch 8.2.1154: Vim9: crash when using imported function
Problem: Vim9: crash when using imported function.
Solution: Check for a function type. Set the script context when calling a
function. (closes #6412)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 08 Jul 2020 15:30:04 +0200 |
parents | 7ee565134d4a |
children | 8d1d11afd8c8 |
comparison
equal
deleted
inserted
replaced
21205:d7f16d42548f | 21206:caab594592cc |
---|---|
66 | 66 |
67 #if defined(FEAT_EVAL) || defined(PROTO) | 67 #if defined(FEAT_EVAL) || defined(PROTO) |
68 /* | 68 /* |
69 * Add a user function to the execution stack. | 69 * Add a user function to the execution stack. |
70 */ | 70 */ |
71 void | 71 estack_T * |
72 estack_push_ufunc(ufunc_T *ufunc, long lnum) | 72 estack_push_ufunc(ufunc_T *ufunc, long lnum) |
73 { | 73 { |
74 estack_T *entry = estack_push(ETYPE_UFUNC, | 74 estack_T *entry = estack_push(ETYPE_UFUNC, |
75 ufunc->uf_name_exp != NULL | 75 ufunc->uf_name_exp != NULL |
76 ? ufunc->uf_name_exp : ufunc->uf_name, lnum); | 76 ? ufunc->uf_name_exp : ufunc->uf_name, lnum); |
77 if (entry != NULL) | 77 if (entry != NULL) |
78 entry->es_info.ufunc = ufunc; | 78 entry->es_info.ufunc = ufunc; |
79 return entry; | |
79 } | 80 } |
80 | 81 |
81 /* | 82 /* |
82 * Return TRUE if "ufunc" with "lnum" is already at the top of the exe stack. | 83 * Return TRUE if "ufunc" with "lnum" is already at the top of the exe stack. |
83 */ | 84 */ |
95 && entry->es_lnum == lnum; | 96 && entry->es_lnum == lnum; |
96 } | 97 } |
97 #endif | 98 #endif |
98 | 99 |
99 /* | 100 /* |
100 * Take an item off of the execution stack. | 101 * Take an item off of the execution stack and return it. |
101 */ | 102 */ |
102 void | 103 estack_T * |
103 estack_pop(void) | 104 estack_pop(void) |
104 { | 105 { |
105 if (exestack.ga_len > 1) | 106 if (exestack.ga_len == 0) |
106 --exestack.ga_len; | 107 return NULL; |
108 --exestack.ga_len; | |
109 return ((estack_T *)exestack.ga_data) + exestack.ga_len; | |
107 } | 110 } |
108 | 111 |
109 /* | 112 /* |
110 * Get the current value for <sfile> in allocated memory. | 113 * Get the current value for <sfile> in allocated memory. |
111 */ | 114 */ |