To: vim_dev@googlegroups.com Subject: Patch 9.0.1205 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1205 Problem: Crash when handling class that extends another class with more than one object members. Solution: Correct pointer computations. (closes #11824) Files: src/vim9class.c, src/testdir/test_vim9_class.vim *** ../vim-9.0.1204/src/vim9class.c 2023-01-14 13:12:01.858485739 +0000 --- src/vim9class.c 2023-01-15 20:43:32.491724361 +0000 *************** *** 182,191 **** for (int i = 0; i < parent_count; ++i) { // parent members need to be copied ! *members[i] = parent_members[i]; ! members[i]->ocm_name = vim_strsave(members[i]->ocm_name); ! if (members[i]->ocm_init != NULL) ! members[i]->ocm_init = vim_strsave(members[i]->ocm_init); } if (gap->ga_len > 0) // new members are moved --- 182,192 ---- for (int i = 0; i < parent_count; ++i) { // parent members need to be copied ! ocmember_T *m = *members + i; ! *m = parent_members[i]; ! m->ocm_name = vim_strsave(m->ocm_name); ! if (m->ocm_init != NULL) ! m->ocm_init = vim_strsave(m->ocm_init); } if (gap->ga_len > 0) // new members are moved *** ../vim-9.0.1204/src/testdir/test_vim9_class.vim 2023-01-15 20:18:51.472362682 +0000 --- src/testdir/test_vim9_class.vim 2023-01-15 20:48:21.815595358 +0000 *************** *** 1081,1086 **** --- 1081,1106 ---- var c = Child.new() END v9.CheckScriptFailure(lines, 'E1325: Method not found on class "Child": new(') + + # base class with more than one object member + lines =<< trim END + vim9script + + class Result + this.success: bool + this.value: any = null + endclass + + class Success extends Result + def new(this.value = v:none) + this.success = true + enddef + endclass + + var v = Success.new('asdf') + assert_equal("object of Success {success: true, value: 'asdf'}", string(v)) + END + v9.CheckScriptSuccess(lines) enddef def Test_class_import() *** ../vim-9.0.1204/src/version.c 2023-01-15 20:18:51.472362682 +0000 --- src/version.c 2023-01-15 20:46:30.855638657 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1205, /**/ -- hundred-and-one symptoms of being an internet addict: 21. Your dog has its own home page. /// Bram Moolenaar -- Bram@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 ///