diff options
author | Bram Moolenaar <Bram@vim.org> | 2023-02-18 14:42:44 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-02-18 14:42:44 +0000 |
commit | 0917e867632199883c07c2d7534f7091b1d12607 (patch) | |
tree | 803dcaf3a0803718b7d08dd6d356132543f5869a /src/vim9type.c | |
parent | 9de960ace0f017fcfeaf64a2f6492f0f88b11fdb (diff) |
patch 9.0.1320: checking the type of a null object causes a crashv9.0.1320
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.
Diffstat (limited to 'src/vim9type.c')
-rw-r--r-- | src/vim9type.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/vim9type.c b/src/vim9type.c index 075eb60d54..c9f72df91b 100644 --- a/src/vim9type.c +++ b/src/vim9type.c @@ -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) |