diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-12-14 19:20:02 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-12-14 19:20:02 +0100 |
commit | 06d4c4c818fe4258bdc3d455b7680fabadd719e4 (patch) | |
tree | a61bbfc666f67788c3f3240ca30324d960243d25 /src/GvimExt | |
parent | eae8ae1b2b4e532b125077d9838b70d966891be3 (diff) | |
download | vim-git-06d4c4c818fe4258bdc3d455b7680fabadd719e4.tar.gz |
patch 8.1.0587: GvimExt: realloc() failing is not handled properlyv8.1.0587
Problem: GvimExt: realloc() failing is not handled properly.
Solution: Check for NULL return. (Jan-Jaap Korpershoek, closes #3689)
Diffstat (limited to 'src/GvimExt')
-rw-r--r-- | src/GvimExt/gvimext.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/GvimExt/gvimext.cpp b/src/GvimExt/gvimext.cpp index 64c5d1339..62d925b8a 100644 --- a/src/GvimExt/gvimext.cpp +++ b/src/GvimExt/gvimext.cpp @@ -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; |