Commit: patch 9.1.2010: Missing out-of-memory checks in vim9class.c

0 views
Skip to first unread message

Christian Brabandt

unread,
2:00 PM (7 hours ago) 2:00 PM
to vim...@googlegroups.com
patch 9.1.2010: Missing out-of-memory checks in vim9class.c

Commit: https://github.com/vim/vim/commit/a90e80411accf01ee55a901d9fd673609de3e6f7
Author: John Marriott <basi...@internode.on.net>
Date: Mon Dec 22 18:49:43 2025 +0000

patch 9.1.2010: Missing out-of-memory checks in vim9class.c

Problem: Missing out-of-memory checks in vim9class.c
(after v9.1.2000)
Solution: Return FAIL early (John Marriott)

closes: #18991

Signed-off-by: John Marriott <basi...@internode.on.net>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/version.c b/src/version.c
index 28336399b..dd8fdd667 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 */
+/**/
+ 2010,
/**/
2009,
/**/
diff --git a/src/vim9class.c b/src/vim9class.c
index e5b811b91..409bb50f7 100644
--- a/src/vim9class.c
+++ b/src/vim9class.c
@@ -179,7 +179,10 @@ add_member(
m->ocm_name.length = (size_t)(varname_end - varname);
m->ocm_name.string = vim_strnsave(varname, m->ocm_name.length);
if (m->ocm_name.string == NULL)
+ {
m->ocm_name.length = 0;
+ return FAIL;
+ }
m->ocm_access = has_public ? VIM_ACCESS_ALL
: *varname == '_' ? VIM_ACCESS_PRIVATE : VIM_ACCESS_READ;
if (has_final)
@@ -230,7 +233,10 @@ add_members_to_class(
*m = parent_members[i];
m->ocm_name.string = vim_strnsave(m->ocm_name.string, m->ocm_name.length);
if (m->ocm_name.string == NULL)
+ {
m->ocm_name.length = 0;
+ return FAIL;
+ }
if (m->ocm_init != NULL)
m->ocm_init = vim_strsave(m->ocm_init);
}
Reply all
Reply to author
Forward
0 new messages