1
0
forked from aniani/vim

patch 9.1.0513: Vim9: segfault with object comparison

Problem:  Vim9: segfault with object comparisons
Solution: increment recusive_cnt before calling typval_compare_object()
          (Ernie Rael)

closes: #15073

Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Ernie Rael 2024-06-22 11:12:00 +02:00 committed by Christian Brabandt
parent 7002c055d5
commit f0e6914420
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
3 changed files with 22 additions and 0 deletions

View File

@ -10486,6 +10486,24 @@ def Test_Ref_Class_Within_Same_Class()
v9.CheckScriptFailure(lines, 'E1347: Not a valid interface: A', 3)
enddef
" Test for comparing a class referencing itself
def Test_Object_Compare_With_Recursive_Class_Ref()
var lines =<< trim END
vim9script
class C
public var nest: C
endclass
var o1 = C.new()
o1.nest = o1
var result = o1 == o1
assert_equal(true, result)
END
v9.CheckScriptSuccess(lines)
enddef
" Test for using a compound operator from a lambda function in an object method
def Test_compound_op_in_objmethod_lambda()
# Test using the "+=" operator

View File

@ -2114,7 +2114,9 @@ tv_equal(
return tv1->vval.v_class == tv2->vval.v_class;
case VAR_OBJECT:
++recursive_cnt;
(void)typval_compare_object(tv1, tv2, EXPR_EQUAL, ic, &r);
--recursive_cnt;
return r;
case VAR_PARTIAL:

View File

@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
513,
/**/
512,
/**/