changeset 7368:adc796ba7dda v7.4.989

commit https://github.com/vim/vim/commit/0107f5ba87ca9427500d0fc42ec80a1f3fca9fdb Author: Bram Moolenaar <Bram@vim.org> Date: Mon Dec 28 22:51:20 2015 +0100 patch 7.4.989 Problem: Leaking memory when hash_add() fails. Coverity error 99126. Solution: When hash_add() fails free the memory.
author Christian Brabandt <cb@256bit.org>
date Mon, 28 Dec 2015 23:00:04 +0100
parents 49b3b41dfe5c
children b94edf952c5e
files src/eval.c src/version.c
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -23095,7 +23095,11 @@ ex_function(eap)
 
 	/* insert the new function in the function list */
 	STRCPY(fp->uf_name, name);
-	hash_add(&func_hashtab, UF2HIKEY(fp));
+	if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL)
+	{
+	    vim_free(fp);
+	    goto erret;
+	}
     }
     fp->uf_args = newargs;
     fp->uf_lines = newlines;
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    989,
+/**/
     988,
 /**/
     987,