changeset 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 6dbef27978d6
children 5c59df6e1835
files src/channel.c src/version.c
diffstat 2 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/channel.c
+++ b/src/channel.c
@@ -2142,7 +2142,7 @@ channel_exe_cmd(channel_T *channel, int 
 	}
 	else
 	{
-	    typval_T	*tv;
+	    typval_T	*tv = NULL;
 	    typval_T	res_tv;
 	    typval_T	err_tv;
 	    char_u	*json = NULL;
@@ -2159,8 +2159,6 @@ channel_exe_cmd(channel_T *channel, int 
 		ch_logs(channel, "Calling '%s'", (char *)arg);
 		if (func_call(arg, &argv[2], NULL, NULL, &res_tv) == OK)
 		    tv = &res_tv;
-		else
-		    tv = NULL;
 	    }
 
 	    if (argv[id_idx].v_type == VAR_NUMBER)
@@ -2174,11 +2172,9 @@ channel_exe_cmd(channel_T *channel, int 
 		    /* If evaluation failed or the result can't be encoded
 		     * then return the string "ERROR". */
 		    vim_free(json);
-		    free_tv(tv);
 		    err_tv.v_type = VAR_STRING;
 		    err_tv.vval.v_string = (char_u *)"ERROR";
-		    tv = &err_tv;
-		    json = json_encode_nr_expr(id, tv, options | JSON_NL);
+		    json = json_encode_nr_expr(id, &err_tv, options | JSON_NL);
 		}
 		if (json != NULL)
 		{
@@ -2191,7 +2187,7 @@ channel_exe_cmd(channel_T *channel, int 
 	    --emsg_skip;
 	    if (tv == &res_tv)
 		clear_tv(tv);
-	    else if (tv != &err_tv)
+	    else
 		free_tv(tv);
 	}
     }
--- a/src/version.c
+++ b/src/version.c
@@ -764,6 +764,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2327,
+/**/
     2326,
 /**/
     2325,