changeset 15154:eb0d8065d3f8 v8.1.0587

patch 8.1.0587: GvimExt: realloc() failing is not handled properly commit https://github.com/vim/vim/commit/06d4c4c818fe4258bdc3d455b7680fabadd719e4 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Dec 14 19:20:02 2018 +0100 patch 8.1.0587: GvimExt: realloc() failing is not handled properly Problem: GvimExt: realloc() failing is not handled properly. Solution: Check for NULL return. (Jan-Jaap Korpershoek, closes https://github.com/vim/vim/issues/3689)
author Bram Moolenaar <Bram@vim.org>
date Fri, 14 Dec 2018 19:30:07 +0100
parents e93f2f958e5e
children 891f2e5dca0b
files src/GvimExt/gvimext.cpp src/version.c
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/GvimExt/gvimext.cpp
+++ b/src/GvimExt/gvimext.cpp
@@ -1024,6 +1024,8 @@ STDMETHODIMP CShellExt::InvokeSingleGvim
 
     cmdlen = BUFSIZE;
     cmdStrW  = (wchar_t *) malloc(cmdlen * sizeof(wchar_t));
+    if (cmdStrW == NULL)
+	return;
     getGvimInvocationW(cmdStrW);
 
     if (useDiff)
@@ -1039,7 +1041,10 @@ STDMETHODIMP CShellExt::InvokeSingleGvim
 	if (len > cmdlen)
 	{
 	    cmdlen = len + BUFSIZE;
-	    cmdStrW = (wchar_t *)realloc(cmdStrW, cmdlen * sizeof(wchar_t));
+	    wchar_t *cmdStrW_new = (wchar_t *)realloc(cmdStrW, cmdlen * sizeof(wchar_t));
+	    if (cmdStrW_new == NULL)
+		goto theend;
+	    cmdStrW = cmdStrW_new;
 	}
 	wcscat(cmdStrW, L" \"");
 	wcscat(cmdStrW, m_szFileUserClickedOn);
@@ -1076,7 +1081,7 @@ STDMETHODIMP CShellExt::InvokeSingleGvim
 	CloseHandle(pi.hProcess);
 	CloseHandle(pi.hThread);
     }
-
+theend:
     free(cmdStrW);
 
     return NOERROR;
--- a/src/version.c
+++ b/src/version.c
@@ -800,6 +800,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    587,
+/**/
     586,
 /**/
     585,