mirror of
https://github.com/vim/vim
synced 2025-07-16 01:01:58 +00:00
patch 9.1.1434: MS-Windows: missing out-of-memory checks in os_win32.c
Problem: MS-Windows: missing out-of-memory checks in os_win32.c Solution: Add out-of-memory checks to os_win32.c (John Marriott) closes: #17441 Signed-off-by: John Marriott <basilisk@internode.on.net> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
8f751d56f4
commit
738df3887f
@ -1962,14 +1962,19 @@ encode_mouse_event(dict_T *args, INPUT_RECORD *ir)
|
|||||||
static int
|
static int
|
||||||
write_input_record_buffer(INPUT_RECORD* irEvents, int nLength)
|
write_input_record_buffer(INPUT_RECORD* irEvents, int nLength)
|
||||||
{
|
{
|
||||||
int nCount = 0;
|
int nCount = 0;
|
||||||
|
input_record_buffer_node_T *event_node;
|
||||||
|
|
||||||
while (nCount < nLength)
|
while (nCount < nLength)
|
||||||
{
|
{
|
||||||
input_record_buffer.length++;
|
event_node = alloc(sizeof(input_record_buffer_node_T));
|
||||||
input_record_buffer_node_T *event_node =
|
if (event_node == NULL)
|
||||||
malloc(sizeof(input_record_buffer_node_T));
|
return -1;
|
||||||
|
|
||||||
event_node->ir = irEvents[nCount++];
|
event_node->ir = irEvents[nCount++];
|
||||||
event_node->next = NULL;
|
event_node->next = NULL;
|
||||||
|
|
||||||
|
input_record_buffer.length++;
|
||||||
if (input_record_buffer.tail == NULL)
|
if (input_record_buffer.tail == NULL)
|
||||||
{
|
{
|
||||||
input_record_buffer.head = event_node;
|
input_record_buffer.head = event_node;
|
||||||
@ -2065,7 +2070,13 @@ test_mswin_event(char_u *event, dict_T *args)
|
|||||||
// events. But, this doesn't work well in the CI test environment. So
|
// events. But, this doesn't work well in the CI test environment. So
|
||||||
// implementing an input_record_buffer instead.
|
// implementing an input_record_buffer instead.
|
||||||
if (input_encoded)
|
if (input_encoded)
|
||||||
lpEventsWritten = write_input_record_buffer(&ir, 1);
|
{
|
||||||
|
if ((lpEventsWritten = write_input_record_buffer(&ir, 1)) < 0)
|
||||||
|
{
|
||||||
|
semsg(_(e_out_of_memory), "event");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set flags to execute the event, ie. like feedkeys mode X.
|
// Set flags to execute the event, ie. like feedkeys mode X.
|
||||||
if (execute)
|
if (execute)
|
||||||
@ -3017,6 +3028,8 @@ mch_init_g(void)
|
|||||||
STRCPY(gettail(vimrun_location), "vimrun.exe");
|
STRCPY(gettail(vimrun_location), "vimrun.exe");
|
||||||
if (mch_getperm(vimrun_location) >= 0)
|
if (mch_getperm(vimrun_location) >= 0)
|
||||||
{
|
{
|
||||||
|
char *p;
|
||||||
|
|
||||||
if (*skiptowhite(vimrun_location) != NUL)
|
if (*skiptowhite(vimrun_location) != NUL)
|
||||||
{
|
{
|
||||||
// Enclose path with white space in double quotes.
|
// Enclose path with white space in double quotes.
|
||||||
@ -3028,8 +3041,12 @@ mch_init_g(void)
|
|||||||
else
|
else
|
||||||
STRCPY(gettail(vimrun_location), "vimrun ");
|
STRCPY(gettail(vimrun_location), "vimrun ");
|
||||||
|
|
||||||
vimrun_path = (char *)vim_strsave(vimrun_location);
|
p = (char *)vim_strsave(vimrun_location);
|
||||||
s_dont_use_vimrun = FALSE;
|
if (p != NULL)
|
||||||
|
{
|
||||||
|
vimrun_path = p;
|
||||||
|
s_dont_use_vimrun = FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (executable_exists("vimrun.exe", NULL, TRUE, FALSE))
|
else if (executable_exists("vimrun.exe", NULL, TRUE, FALSE))
|
||||||
s_dont_use_vimrun = FALSE;
|
s_dont_use_vimrun = FALSE;
|
||||||
@ -7849,7 +7866,10 @@ copy_substream(HANDLE sh, void *context, WCHAR *to, WCHAR *substream, long len)
|
|||||||
HANDLE hTo;
|
HANDLE hTo;
|
||||||
WCHAR *to_name;
|
WCHAR *to_name;
|
||||||
|
|
||||||
to_name = malloc((wcslen(to) + wcslen(substream) + 1) * sizeof(WCHAR));
|
to_name = alloc((wcslen(to) + wcslen(substream) + 1) * sizeof(WCHAR));
|
||||||
|
if (to_name == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
wcscpy(to_name, to);
|
wcscpy(to_name, to);
|
||||||
wcscat(to_name, substream);
|
wcscat(to_name, substream);
|
||||||
|
|
||||||
@ -8194,7 +8214,7 @@ get_cmd_argsW(char ***argvp)
|
|||||||
ArglistW = CommandLineToArgvW(GetCommandLineW(), &nArgsW);
|
ArglistW = CommandLineToArgvW(GetCommandLineW(), &nArgsW);
|
||||||
if (ArglistW != NULL)
|
if (ArglistW != NULL)
|
||||||
{
|
{
|
||||||
argv = malloc((nArgsW + 1) * sizeof(char *));
|
argv = alloc((nArgsW + 1) * sizeof(char *));
|
||||||
if (argv != NULL)
|
if (argv != NULL)
|
||||||
{
|
{
|
||||||
argc = nArgsW;
|
argc = nArgsW;
|
||||||
@ -8226,7 +8246,7 @@ get_cmd_argsW(char ***argvp)
|
|||||||
{
|
{
|
||||||
if (used_file_indexes != NULL)
|
if (used_file_indexes != NULL)
|
||||||
free(used_file_indexes);
|
free(used_file_indexes);
|
||||||
used_file_indexes = malloc(argc * sizeof(int));
|
used_file_indexes = alloc(argc * sizeof(int));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argvp != NULL)
|
if (argvp != NULL)
|
||||||
|
@ -709,6 +709,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 */
|
||||||
|
/**/
|
||||||
|
1434,
|
||||||
/**/
|
/**/
|
||||||
1433,
|
1433,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user