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:
John Marriott
2026-04-15 17:54:22 +00:00
committed by Christian Brabandt
parent 60e925ca0e
commit 7cc73a6c66
2 changed files with 12 additions and 0 deletions
+10
View File
@@ -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;
}
}
+2
View File
@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
353,
/**/
352,
/**/