Mercurial > vim
comparison src/channel.c @ 10112:90b9898d05a6 v7.4.2327
commit https://github.com/vim/vim/commit/c8fe338d64cc6183c03d4c12b1e036a7745e2932
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Sep 4 20:44:42 2016 +0200
patch 7.4.2327
Problem: Freeing a variable that is on the stack.
Solution: Don't free res_tv or err_tv. (Ozaki Kiichi)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 04 Sep 2016 20:45:06 +0200 |
parents | d4b7232fc63a |
children | 65afd399ffa7 |
comparison
equal
deleted
inserted
replaced
10111:6dbef27978d6 | 10112:90b9898d05a6 |
---|---|
2140 if (p_verbose > 2) | 2140 if (p_verbose > 2) |
2141 EMSG(_("E904: third argument for call must be a list")); | 2141 EMSG(_("E904: third argument for call must be a list")); |
2142 } | 2142 } |
2143 else | 2143 else |
2144 { | 2144 { |
2145 typval_T *tv; | 2145 typval_T *tv = NULL; |
2146 typval_T res_tv; | 2146 typval_T res_tv; |
2147 typval_T err_tv; | 2147 typval_T err_tv; |
2148 char_u *json = NULL; | 2148 char_u *json = NULL; |
2149 | 2149 |
2150 /* Don't pollute the display with errors. */ | 2150 /* Don't pollute the display with errors. */ |
2157 else | 2157 else |
2158 { | 2158 { |
2159 ch_logs(channel, "Calling '%s'", (char *)arg); | 2159 ch_logs(channel, "Calling '%s'", (char *)arg); |
2160 if (func_call(arg, &argv[2], NULL, NULL, &res_tv) == OK) | 2160 if (func_call(arg, &argv[2], NULL, NULL, &res_tv) == OK) |
2161 tv = &res_tv; | 2161 tv = &res_tv; |
2162 else | |
2163 tv = NULL; | |
2164 } | 2162 } |
2165 | 2163 |
2166 if (argv[id_idx].v_type == VAR_NUMBER) | 2164 if (argv[id_idx].v_type == VAR_NUMBER) |
2167 { | 2165 { |
2168 int id = argv[id_idx].vval.v_number; | 2166 int id = argv[id_idx].vval.v_number; |
2172 if (tv == NULL || (json != NULL && *json == NUL)) | 2170 if (tv == NULL || (json != NULL && *json == NUL)) |
2173 { | 2171 { |
2174 /* If evaluation failed or the result can't be encoded | 2172 /* If evaluation failed or the result can't be encoded |
2175 * then return the string "ERROR". */ | 2173 * then return the string "ERROR". */ |
2176 vim_free(json); | 2174 vim_free(json); |
2177 free_tv(tv); | |
2178 err_tv.v_type = VAR_STRING; | 2175 err_tv.v_type = VAR_STRING; |
2179 err_tv.vval.v_string = (char_u *)"ERROR"; | 2176 err_tv.vval.v_string = (char_u *)"ERROR"; |
2180 tv = &err_tv; | 2177 json = json_encode_nr_expr(id, &err_tv, options | JSON_NL); |
2181 json = json_encode_nr_expr(id, tv, options | JSON_NL); | |
2182 } | 2178 } |
2183 if (json != NULL) | 2179 if (json != NULL) |
2184 { | 2180 { |
2185 channel_send(channel, | 2181 channel_send(channel, |
2186 part == PART_SOCK ? PART_SOCK : PART_IN, | 2182 part == PART_SOCK ? PART_SOCK : PART_IN, |
2189 } | 2185 } |
2190 } | 2186 } |
2191 --emsg_skip; | 2187 --emsg_skip; |
2192 if (tv == &res_tv) | 2188 if (tv == &res_tv) |
2193 clear_tv(tv); | 2189 clear_tv(tv); |
2194 else if (tv != &err_tv) | 2190 else |
2195 free_tv(tv); | 2191 free_tv(tv); |
2196 } | 2192 } |
2197 } | 2193 } |
2198 else if (p_verbose > 2) | 2194 else if (p_verbose > 2) |
2199 { | 2195 { |