Mercurial > vim
comparison src/testdir/test_vim9_class.vim @ 31525:f7c82a85e88a v9.0.1095
patch 9.0.1095: using freed memory when declaration fails
Commit: https://github.com/vim/vim/commit/6ef5471afa69a654888bc285a51a6035405d33a0
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Dec 25 19:31:36 2022 +0000
patch 9.0.1095: using freed memory when declaration fails
Problem: Using freed memory when declaration fails. (Yegappan Lakshmanan)
Solution: After unreferencing an object set the reference to NULL.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 25 Dec 2022 20:45:04 +0100 |
parents | 065e4ccf5e10 |
children | 9f2a9dd57226 |
comparison
equal
deleted
inserted
replaced
31524:1996a311ac70 | 31525:f7c82a85e88a |
---|---|
347 | 347 |
348 var c2 = MyCar.new("123") | 348 var c2 = MyCar.new("123") |
349 assert_equal('make = 123', c2.GetMake()) | 349 assert_equal('make = 123', c2.GetMake()) |
350 END | 350 END |
351 v9.CheckScriptSuccess(lines) | 351 v9.CheckScriptSuccess(lines) |
352 | |
353 lines =<< trim END | |
354 vim9script | |
355 | |
356 class MyCar | |
357 this.make: string | |
358 | |
359 def new(make_arg: string) | |
360 this.make = make_arg | |
361 enddef | |
362 endclass | |
363 | |
364 var c = MyCar.new("abc") | |
365 var c = MyCar.new("def") | |
366 END | |
367 v9.CheckScriptFailure(lines, 'E1041:') | |
352 enddef | 368 enddef |
353 | 369 |
354 def Test_class_member_access() | 370 def Test_class_member_access() |
355 var lines =<< trim END | 371 var lines =<< trim END |
356 vim9script | 372 vim9script |