Mercurial > vim
comparison src/ops.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 | 50aa6da392ce |
children | ac42c4b11dbc |
comparison
equal
deleted
inserted
replaced
13201:e57e06cfb76b | 13202:2941a86f8aaa |
---|---|
2111 #endif | 2111 #endif |
2112 char_u *newp, *oldp; | 2112 char_u *newp, *oldp; |
2113 size_t oldlen; | 2113 size_t oldlen; |
2114 struct block_def bd; | 2114 struct block_def bd; |
2115 char_u *after_p = NULL; | 2115 char_u *after_p = NULL; |
2116 int had_ctrl_v_cr = (c == -1 || c == -2); | 2116 int had_ctrl_v_cr = FALSE; |
2117 | 2117 |
2118 if ((curbuf->b_ml.ml_flags & ML_EMPTY ) || oap->empty) | 2118 if ((curbuf->b_ml.ml_flags & ML_EMPTY ) || oap->empty) |
2119 return OK; /* nothing to do */ | 2119 return OK; /* nothing to do */ |
2120 | 2120 |
2121 if (had_ctrl_v_cr) | 2121 if (c == REPLACE_CR_NCHAR) |
2122 c = (c == -1 ? '\r' : '\n'); | 2122 { |
2123 had_ctrl_v_cr = TRUE; | |
2124 c = CAR; | |
2125 } | |
2126 else if (c == REPLACE_NL_NCHAR) | |
2127 { | |
2128 had_ctrl_v_cr = TRUE; | |
2129 c = NL; | |
2130 } | |
2123 | 2131 |
2124 #ifdef FEAT_MBYTE | 2132 #ifdef FEAT_MBYTE |
2125 if (has_mbyte) | 2133 if (has_mbyte) |
2126 mb_adjust_opend(oap); | 2134 mb_adjust_opend(oap); |
2127 #endif | 2135 #endif |
2205 mch_memmove(newp, oldp, (size_t)bd.textcol); | 2213 mch_memmove(newp, oldp, (size_t)bd.textcol); |
2206 oldp += bd.textcol + bd.textlen; | 2214 oldp += bd.textcol + bd.textlen; |
2207 /* insert pre-spaces */ | 2215 /* insert pre-spaces */ |
2208 vim_memset(newp + bd.textcol, ' ', (size_t)bd.startspaces); | 2216 vim_memset(newp + bd.textcol, ' ', (size_t)bd.startspaces); |
2209 /* insert replacement chars CHECK FOR ALLOCATED SPACE */ | 2217 /* insert replacement chars CHECK FOR ALLOCATED SPACE */ |
2210 /* -1/-2 is used for entering CR literally. */ | 2218 /* REPLACE_CR_NCHAR/REPLACE_NL_NCHAR is used for entering CR |
2219 * literally. */ | |
2211 if (had_ctrl_v_cr || (c != '\r' && c != '\n')) | 2220 if (had_ctrl_v_cr || (c != '\r' && c != '\n')) |
2212 { | 2221 { |
2213 #ifdef FEAT_MBYTE | 2222 #ifdef FEAT_MBYTE |
2214 if (has_mbyte) | 2223 if (has_mbyte) |
2215 { | 2224 { |
6368 | 6377 |
6369 /* New style with a bar line. Format: | 6378 /* New style with a bar line. Format: |
6370 * |{bartype},{flags},{name},{type}, | 6379 * |{bartype},{flags},{name},{type}, |
6371 * {linecount},{width},{timestamp},"line1","line2" | 6380 * {linecount},{width},{timestamp},"line1","line2" |
6372 * flags: REG_PREVIOUS - register is y_previous | 6381 * flags: REG_PREVIOUS - register is y_previous |
6373 * REG_EXEC - used for @@ | 6382 * REG_EXEC - used for @@ |
6374 */ | 6383 */ |
6375 if (y_previous == &y_regs[i]) | 6384 if (y_previous == &y_regs[i]) |
6376 flags |= REG_PREVIOUS; | 6385 flags |= REG_PREVIOUS; |
6377 if (c == execreg_lastc) | 6386 if (c == execreg_lastc) |
6378 flags |= REG_EXEC; | 6387 flags |= REG_EXEC; |