]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0353: Missing out-of-memory check in register.c v9.2.0353
authorJohn Marriott <basilisk@internode.on.net>
Wed, 15 Apr 2026 17:54:22 +0000 (17:54 +0000)
committerChristian Brabandt <cb@256bit.org>
Wed, 15 Apr 2026 17:54:22 +0000 (17:54 +0000)
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>
src/register.c
src/version.c

index a20e5c1d0f6d3753778ab501124573ff149be038..0215f0153d92465df094a7f6952bb57c088732f5 100644 (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;
            }
        }
index 2eb306c56beeb06c0bec7c16c00e73f203557f20..2f48f475e9457928aace2d8ab17b56acaa9d5d62 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    353,
 /**/
     352,
 /**/