0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 9.0.1317: crash when using an unset object variable

Problem:    Crash when using an unset object variable.
Solution:   Give an error instead. (closes #12005)
This commit is contained in:
Bram Moolenaar
2023-02-17 21:08:50 +00:00
parent eea0a00811
commit 552bdca781
4 changed files with 34 additions and 7 deletions

View File

@@ -1234,9 +1234,6 @@ class_object_index(
evalarg_T *evalarg,
int verbose UNUSED) // give error messages
{
// int evaluate = evalarg != NULL
// && (evalarg->eval_flags & EVAL_EVALUATE);
if (VIM_ISWHITE((*arg)[1]))
{
semsg(_(e_no_white_space_allowed_after_str_str), ".", *arg);
@@ -1250,8 +1247,19 @@ class_object_index(
return FAIL;
size_t len = name_end - name;
class_T *cl = rettv->v_type == VAR_CLASS ? rettv->vval.v_class
: rettv->vval.v_object->obj_class;
class_T *cl;
if (rettv->v_type == VAR_CLASS)
cl = rettv->vval.v_class;
else // VAR_OBJECT
{
if (rettv->vval.v_object == NULL)
{
emsg(_(e_using_null_object));
return FAIL;
}
cl = rettv->vval.v_object->obj_class;
}
if (*name_end == '(')
{
int on_class = rettv->v_type == VAR_CLASS;