comparison src/normal.c @ 13202:2941a86f8aaa v8.0.1475

patch 8.0.1475: invalid memory access in read_redo() commit https://github.com/vim/vim/commit/f12519dec88251305793f1651f558d16506b4be2 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Feb 6 22:52:49 2018 +0100 patch 8.0.1475: invalid memory access in read_redo() Problem: Invalid memory access in read_redo(). (gy741) Solution: Convert the replacement character back from a negative number to CR or NL. (hint by Dominique Pelle, closes #2616)
author Christian Brabandt <cb@256bit.org>
date Tue, 06 Feb 2018 23:00:07 +0100
parents 3dd37eec73f0
children ac42c4b11dbc
comparison
equal deleted inserted replaced
13201:e57e06cfb76b 13202:2941a86f8aaa
1683 || cap->nchar == 'N')) 1683 || cap->nchar == 'N'))
1684 prep_redo(oap->regname, cap->count0, 1684 prep_redo(oap->regname, cap->count0,
1685 get_op_char(oap->op_type), get_extra_op_char(oap->op_type), 1685 get_op_char(oap->op_type), get_extra_op_char(oap->op_type),
1686 oap->motion_force, cap->cmdchar, cap->nchar); 1686 oap->motion_force, cap->cmdchar, cap->nchar);
1687 else if (cap->cmdchar != ':') 1687 else if (cap->cmdchar != ':')
1688 {
1689 int nchar = oap->op_type == OP_REPLACE ? cap->nchar : NUL;
1690
1691 /* reverse what nv_replace() did */
1692 if (nchar == REPLACE_CR_NCHAR)
1693 nchar = CAR;
1694 else if (nchar == REPLACE_NL_NCHAR)
1695 nchar = NL;
1688 prep_redo(oap->regname, 0L, NUL, 'v', 1696 prep_redo(oap->regname, 0L, NUL, 'v',
1689 get_op_char(oap->op_type), 1697 get_op_char(oap->op_type),
1690 get_extra_op_char(oap->op_type), 1698 get_extra_op_char(oap->op_type),
1691 oap->op_type == OP_REPLACE 1699 nchar);
1692 ? cap->nchar : NUL); 1700 }
1693 if (!redo_VIsual_busy) 1701 if (!redo_VIsual_busy)
1694 { 1702 {
1695 redo_VIsual_mode = resel_VIsual_mode; 1703 redo_VIsual_mode = resel_VIsual_mode;
1696 redo_VIsual_vcol = resel_VIsual_vcol; 1704 redo_VIsual_vcol = resel_VIsual_vcol;
1697 redo_VIsual_line_count = resel_VIsual_line_count; 1705 redo_VIsual_line_count = resel_VIsual_line_count;
7021 { 7029 {
7022 if (got_int) 7030 if (got_int)
7023 reset_VIsual(); 7031 reset_VIsual();
7024 if (had_ctrl_v) 7032 if (had_ctrl_v)
7025 { 7033 {
7026 if (cap->nchar == '\r') 7034 /* Use a special (negative) number to make a difference between a
7027 cap->nchar = -1; 7035 * literal CR or NL and a line break. */
7028 else if (cap->nchar == '\n') 7036 if (cap->nchar == CAR)
7029 cap->nchar = -2; 7037 cap->nchar = REPLACE_CR_NCHAR;
7038 else if (cap->nchar == NL)
7039 cap->nchar = REPLACE_NL_NCHAR;
7030 } 7040 }
7031 nv_operator(cap); 7041 nv_operator(cap);
7032 return; 7042 return;
7033 } 7043 }
7034 7044