Commit: patch 9.2.0353: Missing out-of-memory check in register.c

3 views
Skip to first unread message

Christian Brabandt

unread,
Apr 15, 2026, 2:00:16 PMApr 15
to vim...@googlegroups.com
patch 9.2.0353: Missing out-of-memory check in register.c

Commit: https://github.com/vim/vim/commit/7cc73a6c668e43b2018b145af235801e53b95b45
Author: John Marriott <basi...@internode.on.net>
Date: Wed Apr 15 17:54:22 2026 +0000

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 <basi...@internode.on.net>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/register.c b/src/register.c
index a20e5c1d0..0215f0153 100644
--- a/src/register.c
+++ b/src/register.c
@@ -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;
}
}
diff --git a/src/version.c b/src/version.c
index 2eb306c56..2f48f475e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 353,
/**/
352,
/**/
Reply all
Reply to author
Forward
0 new messages