summaryrefslogtreecommitdiff
path: root/src/ops.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-02-06 22:52:49 +0100
committerBram Moolenaar <Bram@vim.org>2018-02-06 22:52:49 +0100
commitf12519dec88251305793f1651f558d16506b4be2 (patch)
tree8aadf8dd05eeee8a35273f34b3cff77f2ed91452 /src/ops.c
parentdd08b6a32b639b8c7a11275e04ae0a7ffc43aed0 (diff)
downloadvim-git-f12519dec88251305793f1651f558d16506b4be2.tar.gz
patch 8.0.1475: invalid memory access in read_redo()v8.0.1475
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)
Diffstat (limited to 'src/ops.c')
-rw-r--r--src/ops.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/ops.c b/src/ops.c
index 83c36bda6..1350d8264 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -2113,13 +2113,21 @@ op_replace(oparg_T *oap, int c)
size_t oldlen;
struct block_def bd;
char_u *after_p = NULL;
- int had_ctrl_v_cr = (c == -1 || c == -2);
+ int had_ctrl_v_cr = FALSE;
if ((curbuf->b_ml.ml_flags & ML_EMPTY ) || oap->empty)
return OK; /* nothing to do */
- if (had_ctrl_v_cr)
- c = (c == -1 ? '\r' : '\n');
+ if (c == REPLACE_CR_NCHAR)
+ {
+ had_ctrl_v_cr = TRUE;
+ c = CAR;
+ }
+ else if (c == REPLACE_NL_NCHAR)
+ {
+ had_ctrl_v_cr = TRUE;
+ c = NL;
+ }
#ifdef FEAT_MBYTE
if (has_mbyte)
@@ -2207,7 +2215,8 @@ op_replace(oparg_T *oap, int c)
/* insert pre-spaces */
vim_memset(newp + bd.textcol, ' ', (size_t)bd.startspaces);
/* insert replacement chars CHECK FOR ALLOCATED SPACE */
- /* -1/-2 is used for entering CR literally. */
+ /* REPLACE_CR_NCHAR/REPLACE_NL_NCHAR is used for entering CR
+ * literally. */
if (had_ctrl_v_cr || (c != '\r' && c != '\n'))
{
#ifdef FEAT_MBYTE
@@ -6370,7 +6379,7 @@ write_viminfo_registers(FILE *fp)
* |{bartype},{flags},{name},{type},
* {linecount},{width},{timestamp},"line1","line2"
* flags: REG_PREVIOUS - register is y_previous
- * REG_EXEC - used for @@
+ * REG_EXEC - used for @@
*/
if (y_previous == &y_regs[i])
flags |= REG_PREVIOUS;