diff src/vim9class.c @ 31746:d3d3ed2c09f6 v9.0.1205

patch 9.0.1205: crash when handling class that extends another class Commit: https://github.com/vim/vim/commit/ae3205aa55741152b0143dbd7d637b35f576793e Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 15 20:49:00 2023 +0000 patch 9.0.1205: crash when handling class that extends another class Problem: Crash when handling class that extends another class with more than one object members. Solution: Correct pointer computations. (closes #11824)
author Bram Moolenaar <Bram@vim.org>
date Sun, 15 Jan 2023 22:00:03 +0100
parents ef7a9a7eb197
children 48431422f766
line wrap: on
line diff
--- a/src/vim9class.c
+++ b/src/vim9class.c
@@ -182,10 +182,11 @@ add_members_to_class(
     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);
+	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