To: vim_dev@googlegroups.com Subject: Patch 8.2.3721 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3721 Problem: Using memory freed by losing the clipboard selection. (Dominique Pellé) Solution: Check y_array is still valid after calling changed_lines(). (closes #9253) Files: src/errors.h, src/register.c *** ../vim-8.2.3720/src/errors.h 2021-12-02 16:38:46.239764508 +0000 --- src/errors.h 2021-12-02 18:24:11.869466196 +0000 *************** *** 316,322 **** INIT(= N_("E1062: Cannot index a Number")); EXTERN char e_type_mismatch_for_v_variable[] INIT(= N_("E1063: Type mismatch for v: variable")); ! // E1064 unused // E1065 unused EXTERN char e_cannot_declare_a_register_str[] INIT(= N_("E1066: Cannot declare a register: %s")); --- 316,323 ---- INIT(= N_("E1062: Cannot index a Number")); EXTERN char e_type_mismatch_for_v_variable[] INIT(= N_("E1063: Type mismatch for v: variable")); ! EXTERN char e_yank_register_changed_while_using_it[] ! INIT(= N_("E1064: Yank register changed while using it")); // E1065 unused EXTERN char e_cannot_declare_a_register_str[] INIT(= N_("E1066: Cannot declare a register: %s")); *** ../vim-8.2.3720/src/register.c 2021-11-25 20:40:07.323401291 +0000 --- src/register.c 2021-12-02 18:19:54.622081023 +0000 *************** *** 1550,1555 **** --- 1532,1538 ---- long j; struct block_def bd; char_u **y_array = NULL; + yankreg_T *y_current_used = NULL; long nr_lines = 0; pos_T new_cursor; int indent; *************** *** 1660,1665 **** --- 1643,1649 ---- y_width = y_current->y_width; y_size = y_current->y_size; y_array = y_current->y_array; + y_current_used = y_current; } if (y_type == MLINE) *************** *** 2208,2213 **** --- 2192,2205 ---- else changed_lines(curbuf->b_op_start.lnum, 0, curbuf->b_op_start.lnum, nr_lines); + if (y_current_used != NULL && (y_current_used != y_current + || y_current->y_array != y_array)) + { + // Something invoked through changed_lines() has changed the + // yank buffer, e.g. a GUI clipboard callback. + emsg(_(e_yank_register_changed_while_using_it)); + goto end; + } // Put the '] mark on the first byte of the last inserted character. // Correct the length for change in indent. *** ../vim-8.2.3720/src/version.c 2021-12-02 16:38:46.243764499 +0000 --- src/version.c 2021-12-02 18:24:09.849470871 +0000 *************** *** 755,756 **** --- 755,758 ---- { /* Add new patch number below this line */ + /**/ + 3721, /**/ -- A village. Sound of chanting of Latin canon, punctuated by short, sharp cracks. It comes nearer. We see it is a line of MONKS ala SEVENTH SEAL flagellation scene, chanting and banging themselves on the foreheads with wooden boards. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///