b6500d
diff --git a/src/normal.c b/src/normal.c
b6500d
index be0e75e..7d62e20 100644
b6500d
--- a/src/normal.c
b6500d
+++ b/src/normal.c
b6500d
@@ -7147,19 +7147,23 @@ nv_replace(cmdarg_T *cap)
b6500d
 	    {
b6500d
 		/*
b6500d
 		 * Get ptr again, because u_save and/or showmatch() will have
b6500d
-		 * released the line.  At the same time we let know that the
b6500d
-		 * line will be changed.
b6500d
+		 * released the line.  This may also happen in ins_copychar().
b6500d
+		 * At the same time we let know that the line will be changed.
b6500d
 		 */
b6500d
-		ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE);
b6500d
 		if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y)
b6500d
 		{
b6500d
 		  int c = ins_copychar(curwin->w_cursor.lnum
b6500d
 					   + (cap->nchar == Ctrl_Y ? -1 : 1));
b6500d
+
b6500d
+		  ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE);
b6500d
 		  if (c != NUL)
b6500d
 		    ptr[curwin->w_cursor.col] = c;
b6500d
 		}
b6500d
 		else
b6500d
+		{
b6500d
+		    ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE);
b6500d
 		    ptr[curwin->w_cursor.col] = cap->nchar;
b6500d
+		}
b6500d
 		if (p_sm && msg_silent == 0)
b6500d
 		    showmatch(cap->nchar);
b6500d
 		++curwin->w_cursor.col;
b6500d
diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim
b6500d
index 7278bcd..8818805 100644
b6500d
--- a/src/testdir/test_edit.vim
b6500d
+++ b/src/testdir/test_edit.vim
b6500d
@@ -1387,3 +1387,15 @@ func Test_edit_quit()
b6500d
   only
b6500d
 endfunc
b6500d
 
b6500d
+" Test for getting the character of the line below after "p"
b6500d
+func Test_edit_put_CTRL_E()
b6500d
+  set encoding=latin1
b6500d
+  new
b6500d
+  let @" = ''
b6500d
+  sil! norm or?ggRx
b6500d
+  sil! norm pr?
b6500d
+  call assert_equal(['r', 'r'], getline(1, 2))
b6500d
+  bwipe!
b6500d
+  set encoding=utf-8
b6500d
+endfunc
b6500d
+