changeset 7340:645abb8d8daf v7.4.975

commit https://github.com/vim/vim/commit/75e3ad019933f4879137775549261bf51985ab7d Author: Bram Moolenaar <Bram@vim.org> Date: Thu Dec 17 15:07:32 2015 +0100 patch 7.4.975 Problem: Using ":sort" on a very big file sometimes causes text to be corrupted. (John Beckett) Solution: Copy the line into a buffer before calling ml_append().
author Christian Brabandt <cb@256bit.org>
date Thu, 17 Dec 2015 15:15:06 +0100
parents 8a8a4b6d799c
children c61a87f9e679
files src/ex_cmds.c src/version.c
diffstat 2 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -540,10 +540,11 @@ ex_sort(eap)
 	if (!unique || i == 0
 		|| (sort_ic ? STRICMP(s, sortbuf1) : STRCMP(s, sortbuf1)) != 0)
 	{
-	    if (ml_append(lnum++, s, (colnr_T)0, FALSE) == FAIL)
+	    /* Copy the line into a buffer, it may become invalid in
+	     * ml_append(). And it's needed for "unique". */
+	    STRCPY(sortbuf1, s);
+	    if (ml_append(lnum++, sortbuf1, (colnr_T)0, FALSE) == FAIL)
 		break;
-	    if (unique)
-		STRCPY(sortbuf1, s);
 	}
 	fast_breakcheck();
 	if (got_int)
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    975,
+/**/
     974,
 /**/
     973,