1
0
forked from aniani/vim

patch 9.0.1320: checking the type of a null object causes a crash

Problem:    Checking the type of a null object causes a crash.
Solution:   Don't try to get the class of a null object. (closes #12005)
            Handle error from calling a user function better.
This commit is contained in:
Bram Moolenaar
2023-02-18 14:42:44 +00:00
parent 9de960ace0
commit 0917e86763
10 changed files with 94 additions and 48 deletions

View File

@@ -1659,7 +1659,8 @@ type_name(type_T *type, char **tofree)
if (type->tt_type == VAR_OBJECT || type->tt_type == VAR_CLASS)
{
char_u *class_name = ((class_T *)type->tt_member)->class_name;
char_u *class_name = type->tt_member == NULL ? (char_u *)"Unknown"
: ((class_T *)type->tt_member)->class_name;
size_t len = STRLEN(name) + STRLEN(class_name) + 3;
*tofree = alloc(len);
if (*tofree != NULL)