0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 9.0.1037: lalloc(0) error for a class without members

Problem:    lalloc(0) error for a class without members.
Solution:   Don't allocate room for members if there aren't any.
            Don't create the class if there was an error.
This commit is contained in:
Bram Moolenaar
2022-12-08 22:09:14 +00:00
parent 3f8f827723
commit 98aeb2100c
2 changed files with 7 additions and 4 deletions

View File

@@ -121,8 +121,8 @@ ex_class(exarg_T *eap)
semsg(_(e_command_cannot_be_shortened_str), line);
else if (*p == '|' || !ends_excmd2(line, p))
semsg(_(e_trailing_characters_str), p);
success = TRUE;
else
success = TRUE;
break;
}
@@ -190,9 +190,10 @@ ex_class(exarg_T *eap)
// Members are used by the new() function, add them here.
cl->class_obj_member_count = objmembers.ga_len;
cl->class_obj_members = ALLOC_MULT(objmember_T, objmembers.ga_len);
cl->class_obj_members = objmembers.ga_len == 0 ? NULL
: ALLOC_MULT(objmember_T, objmembers.ga_len);
if (cl->class_name == NULL
|| cl->class_obj_members == NULL)
|| (objmembers.ga_len > 0 && cl->class_obj_members == NULL))
{
vim_free(cl->class_name);
vim_free(cl->class_obj_members);