]> granicus.if.org Git - vim/commitdiff
patch 8.1.0587: GvimExt: realloc() failing is not handled properly v8.1.0587
authorBram Moolenaar <Bram@vim.org>
Fri, 14 Dec 2018 18:20:02 +0000 (19:20 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 14 Dec 2018 18:20:02 +0000 (19:20 +0100)
Problem:    GvimExt: realloc() failing is not handled properly.
Solution:   Check for NULL return. (Jan-Jaap Korpershoek, closes #3689)

src/GvimExt/gvimext.cpp
src/version.c

index 64c5d1339f8501d2a21cf958a3b8a9d1aa54f75f..62d925b8a222a85e8a0bb3d2732dd7184257843b 100644 (file)
@@ -1024,6 +1024,8 @@ STDMETHODIMP CShellExt::InvokeSingleGvim(HWND hParent,
 
     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(HWND hParent,
        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(HWND hParent,
        CloseHandle(pi.hProcess);
        CloseHandle(pi.hThread);
     }
-
+theend:
     free(cmdStrW);
 
     return NOERROR;
index 9e3f7208a8cc8e06e811436ef9e17a7c2802c791..cc609967a234014c37538f4e7bc623663cc9d827 100644 (file)
@@ -799,6 +799,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    587,
 /**/
     586,
 /**/