mirror of
https://github.com/vim/vim.git
synced 2026-05-28 00:21:37 +02:00
patch 9.2.0353: Missing out-of-memory check in register.c
Problem: Missing out-of-memory check in register.c
Solution: Check for memory allocation failure and return NULL
(John Marriott).
closes: #19949
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
60e925ca0e
commit
7cc73a6c66
@@ -352,6 +352,16 @@ get_register(
|
||||
{
|
||||
reg->y_array[i].string = vim_strnsave(y_current->y_array[i].string,
|
||||
y_current->y_array[i].length);
|
||||
if (reg->y_array[i].string == NULL)
|
||||
{
|
||||
// The allocation failed so clean up and exit
|
||||
while (--i >= 0)
|
||||
vim_free(reg->y_array[i].string);
|
||||
vim_free(reg->y_array);
|
||||
vim_free(reg);
|
||||
return (void *)NULL;
|
||||
}
|
||||
|
||||
reg->y_array[i].length = y_current->y_array[i].length;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -734,6 +734,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
353,
|
||||
/**/
|
||||
352,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user