0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

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 #3689)
This commit is contained in:
Bram Moolenaar
2018-12-14 19:20:02 +01:00
parent eae8ae1b2b
commit 06d4c4c818
2 changed files with 9 additions and 2 deletions

View File

@@ -1024,6 +1024,8 @@ STDMETHODIMP CShellExt::InvokeSingleGvim(HWND hParent,
cmdlen = BUFSIZE; cmdlen = BUFSIZE;
cmdStrW = (wchar_t *) malloc(cmdlen * sizeof(wchar_t)); cmdStrW = (wchar_t *) malloc(cmdlen * sizeof(wchar_t));
if (cmdStrW == NULL)
return;
getGvimInvocationW(cmdStrW); getGvimInvocationW(cmdStrW);
if (useDiff) if (useDiff)
@@ -1039,7 +1041,10 @@ STDMETHODIMP CShellExt::InvokeSingleGvim(HWND hParent,
if (len > cmdlen) if (len > cmdlen)
{ {
cmdlen = len + BUFSIZE; 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, L" \"");
wcscat(cmdStrW, m_szFileUserClickedOn); wcscat(cmdStrW, m_szFileUserClickedOn);
@@ -1076,7 +1081,7 @@ STDMETHODIMP CShellExt::InvokeSingleGvim(HWND hParent,
CloseHandle(pi.hProcess); CloseHandle(pi.hProcess);
CloseHandle(pi.hThread); CloseHandle(pi.hThread);
} }
theend:
free(cmdStrW); free(cmdStrW);
return NOERROR; return NOERROR;

View File

@@ -799,6 +799,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
587,
/**/ /**/
586, 586,
/**/ /**/