diff src/ex_cmds.c @ 16686:6ea3f93b4428 v8.1.1345

patch 8.1.1345: stuck in sandbox with ":s/../=Function/gn" commit https://github.com/vim/vim/commit/6349e9411fd17f80c7aff9c678a8800647d34cfa Author: Bram Moolenaar <Bram@vim.org> Date: Sat May 18 13:41:22 2019 +0200 patch 8.1.1345: stuck in sandbox with ":s/../\=Function/gn" Problem: Stuck in sandbox with ":s/../\=Function/gn". Solution: Don't skip over code to restore sandbox. (Christian Brabandt)
author Bram Moolenaar <Bram@vim.org>
date Sat, 18 May 2019 13:45:04 +0200
parents 1fc9cd08cf3c
children 23af483c4ceb
line wrap: on
line diff
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -5555,28 +5555,25 @@ do_sub(exarg_T *eap)
 #ifdef FEAT_EVAL
 		if (subflags.do_count)
 		{
-		    /* prevent accidentally changing the buffer by a function */
-		    save_ma = curbuf->b_p_ma;
+		    // prevent accidentally changing the buffer by a function
 		    curbuf->b_p_ma = FALSE;
 		    sandbox++;
 		}
-		/* Save flags for recursion.  They can change for e.g.
-		 * :s/^/\=execute("s#^##gn") */
+		// Save flags for recursion.  They can change for e.g.
+		// :s/^/\=execute("s#^##gn")
 		subflags_save = subflags;
-#endif
-		/* get length of substitution part */
+		save_ma = curbuf->b_p_ma;
+#endif
+		// get length of substitution part
 		sublen = vim_regsub_multi(&regmatch,
 				    sub_firstlnum - regmatch.startpos[0].lnum,
 				    sub, sub_firstline, FALSE, p_magic, TRUE);
 #ifdef FEAT_EVAL
 		// If getting the substitute string caused an error, don't do
 		// the replacement.
-		if (aborting())
-		    goto skip;
-
 		// Don't keep flags set by a recursive call.
 		subflags = subflags_save;
-		if (subflags.do_count)
+		if (aborting() || subflags.do_count)
 		{
 		    curbuf->b_p_ma = save_ma;
 		    if (sandbox > 0)