Patch 9.0.1095

6 views
Skip to first unread message

Bram Moolenaar

unread,
Dec 25, 2022, 2:32:55 PM12/25/22
to vim...@googlegroups.com

Patch 9.0.1095
Problem: Using freed memory when declaration fails. (Yegappan Lakshmanan)
Solution: After unreferencing an object set the reference to NULL.
Files: src/typval.c, src/testdir/test_vim9_class.vim


*** ../vim-9.0.1094/src/typval.c 2022-12-08 20:41:55.433288306 +0000
--- src/typval.c 2022-12-25 19:08:23.690457433 +0000
***************
*** 162,170 ****
--- 162,172 ----
break;
case VAR_CLASS:
class_unref(varp->vval.v_class);
+ varp->vval.v_class = NULL;
break;
case VAR_OBJECT:
object_unref(varp->vval.v_object);
+ varp->vval.v_object = NULL;
break;
case VAR_UNKNOWN:
case VAR_ANY:
*** ../vim-9.0.1094/src/testdir/test_vim9_class.vim 2022-12-24 21:23:59.578929527 +0000
--- src/testdir/test_vim9_class.vim 2022-12-25 19:19:14.751363987 +0000
***************
*** 349,354 ****
--- 349,370 ----
assert_equal('make = 123', c2.GetMake())
END
v9.CheckScriptSuccess(lines)
+
+ lines =<< trim END
+ vim9script
+
+ class MyCar
+ this.make: string
+
+ def new(make_arg: string)
+ this.make = make_arg
+ enddef
+ endclass
+
+ var c = MyCar.new("abc")
+ var c = MyCar.new("def")
+ END
+ v9.CheckScriptFailure(lines, 'E1041:')
enddef

def Test_class_member_access()
*** ../vim-9.0.1094/src/version.c 2022-12-25 15:59:19.993863341 +0000
--- src/version.c 2022-12-25 19:15:39.088185105 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1095,
/**/

--
ARTHUR: Listen, old crone! Unless you tell us where we can buy a shrubbery,
my friend and I will ... we will say "Ni!"
CRONE: Do your worst!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages